first search result for averaging streaming data:
https://nestedsoftware.com/2018/03/20/calculating-a-moving-a...
so you just walk the file and read a chunk, update the averages and move on. the resource usage should be 0.000 nothing and speed should be limited by your disk IO.