Using readline allows you to find the end of each line in your file. If some lines are very long, this may cause your interpreter to crash (not enough memory to fill the full line).
To show progress, you can check the file size, for example:
import os
f = open(file_path, 'r')
fsize = os.fstat(f).st_size
As a result of your task, there may be the number of bytes processed divided by the file size 100 times to have a percentage.
source
share