how to count lines in a file ?
Bo M. Maryniuck
b.maryniuk at forbis.lt
Wed Jul 24 09:33:34 EDT 2002
On Wednesday 24 July 2002 13:20, James Kew wrote:
> > i need to count lines in a file (that i *can't* keep in memory, so can't
> use readlines())
Arhhh!.. I've missed this point somehow. Therefore to use smallest code,
shagshag13 should buy more RAM. :o]
> > Now, why on earth would you use that monstrosity instead of:
> >
> > for line in open(filename):
> > count += 1
In anyway this example probably does not work: looping over not sequence and
you probably should use xreadlines().
--
Sincerely yours, Bogdan M. Maryniuck
>Ever heard of .cshrc?
That's a city in Bosnia. Right?
(Discussion in comp.os.linux.misc on the intuitiveness of commands.)
More information about the Python-list
mailing list