Tuesday, November 13, 2012
4:02 PM

Read Large Files Line by Line in Python - Best Way

The readlines() function loads the entire file into memory as it runs. A better approach for large files is to use the fileinput module, as follows:

import fileinput
for line in fileinput.input(['myfile']):
   print(line)

0 comments:

Post a Comment