Re: looping over a big file

2005-07-05 Thread Asun Friere
sorry lost the first line in pasting: Python 2.4.1 (#1, Jun 21 2005, 12:38:55) :/ -- http://mail.python.org/mailman/listinfo/python-list

Re: looping over a big file

2005-07-05 Thread Asun Friere
Jp Calderone wrote: > fileIter = iter(big_file) > for line in fileIter: > line_after = fileIter.next() > > Don't mix iterating with any other file methods, since it will confuse the > buffering scheme. > Isn't a file an iterable already? [GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)]

Re: looping over a big file

2005-07-04 Thread Terry Hancock
On Sunday 03 July 2005 08:28 pm, Peter Hansen wrote: > If open() can ever return things other than files, it seems likely it > will do so only under conditions that make it pretty much safe to assume > that existing code will continue to operate "as expected" (note: not > "always with a file").

Re: looping over a big file

2005-07-03 Thread Peter Hansen
Michael Hoffman wrote: > Mike Meyer wrote: >> Guido has made a pronouncement on open vs. file. I think he prefers >> open for opening files, and file for type testing, but may well be >> wrong. I don't think it's critical. > > He has said that open() may be used for things other than files in the

Re: looping over a big file

2005-07-03 Thread Michael Hoffman
Mike Meyer wrote: > Roy Smith <[EMAIL PROTECTED]> writes: > >>The "right" way to do this is: >> >>for line in file ("filename"): >> whatever >> >>The file object returned by file() acts as an iterator. Each time through >>the loop, another line is read and returned (I'm sure there is some >>b

Re: looping over a big file

2005-07-03 Thread Mike Meyer
Roy Smith <[EMAIL PROTECTED]> writes: > The "right" way to do this is: > > for line in file ("filename"): >whatever > > The file object returned by file() acts as an iterator. Each time through > the loop, another line is read and returned (I'm sure there is some > block-level buffering goin

Re: looping over a big file

2005-07-03 Thread Roy Smith
Jp Calderone <[EMAIL PROTECTED]> wrote: > Yes, but you need to do it like this: > > fileIter = iter(big_file) > for line in fileIter: > line_after = fileIter.next() That's better than the solution I posted. -- http://mail.python.org/mailman/listinfo/python-list

Re: looping over a big file

2005-07-03 Thread Jp Calderone
On Sun, 3 Jul 2005 23:52:12 +0200, martian <[EMAIL PROTECTED]> wrote: >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 us

Re: looping over a big file

2005-07-03 Thread Roy Smith
"martian" <[EMAIL PROTECTED]> wrote: > 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 ...? The "right" way to do this is: for line in file ("filename"): whatever The file object returned by f

looping over a big file

2005-07-03 Thread martian
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 doe