Revision: 18383
Updated Code
at September 29, 2009 11:59 by laurenceosx
Updated Code
f = open('test.zip', 'rb') for data in iter( lambda: f.read(1024) , ''): pass # do stuff # or without lambda f = open('really_big_file.dat') def read1k(): return f.read(1024) for piece in iter(read1k, ''): process_data(piece)
Revision: 18382
Updated Code
at September 29, 2009 11:58 by laurenceosx
Updated Code
f = open('test.zip', 'rb') for data in iter( lambda: f.read(1024) , ''): pass # do stuff ######################################### f = open('really_big_file.dat') def read1k(): return f.read(1024) for piece in iter(read1k, ''): process_data(piece)
Revision: 18381
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 29, 2009 11:39 by laurenceosx
Initial Code
f = open('really_big_file.dat') def read1k(): return f.read(1024) for piece in iter(read1k, ''): process_data(piece)
Initial URL
http://stackoverflow.com/questions/519633/lazy-method-for-reading-big-file-in-python
Initial Description
Initial Title
Lazy Method for Reading Big File in Python?
Initial Tags
python
Initial Language
Python