I'm trying to use pyprint to add a progress bar for processing a large textfile.
My understanding is that that pypring needs the total number of loop iterations before-hand, in order to calculate the progress bars.
However, if you just have a large textfile, there is no way of telling how many lines there are without actually reading through the whole file.
It would be nice if there was some way of setting a progress bar, such that you could give it a total file-size, then update it with the current progress through the file - e.g.
import pyprind
import os
import time
n = os.path.getsize('queries.txt')
bar = pyprind.ProgBar(n)
with open('queries.txt', 'r') as f:
for line in f:
time.sleep(0.5)
# do some computation
# Use f.tell() for current position - pass to bar, somehow
bar.update()