Tuesday, 13 November 2012

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)

Share This!



No comments:

Post a Comment

Here We Write The Problems we face at different situations and Solutions to those problems.