looping over a big file
martian
nospam at hetnet.nl
Sun Jul 3 17:52:12 EDT 2005
Hi,
I've a couple of questions regarding the processing of a big text file
(16MB).
1) how does python handle:
> for line in big_file:
is big_file all read into memory or one line is read at a time or a buffer
is used or ...?
2) is it possible to advance lines within the loop? The following doesn't
work:
> for line in big_file:
line_after = big_file.readline()
the function readline (file pointer) is "out of sync" with the loop (and
this suggests bug_file is not read one line at a time in the loop).
Thanks,
Fernando Martins
More information about the Python-list
mailing list