Text processing and file creation

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Wed Sep 5 12:57:55 EDT 2007


 kyosohma at gmail.com wrote:

> I would use a counter in a for loop using the readline method to
> iterate over the 20,000 line file. 

file objects are iterables themselves, so there's no need to do that
by using a method.

> Reset the counter every 5 lines/ iterations and close the file. 

I'd use a generator that fetches five lines of the file per
iteration and iterate over it instead of the file directly.

> Have fun!

Definitely -- and also do your homework yourself :)

Regards,


Björn

-- 
BOFH excuse #339:

manager in the cable duct




More information about the Python-list mailing list