python 2.7 - Obtain progress in reading large text file -


i have large text file (several gb in size) need read python , process line line.

one approach call data=f.readlines() , process content. approach know total number of lines , can measure progress of processing. not ideal approach given file size.

the alternative (and think better) option say:

    line in f:       

just not sure how measure progress anymore. there option not add huge overhead? (one reson why may want know progress 1 have rough indicator of remaining time, lines in file have similar sizes, , ascertain whether script still doing or has gotten stuck somewhere.)

if using linux os there way out seems.

a = os.popen("wc -l some.txt") f = a.read() 

on reading number of lines name of file


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -