[Tutor] CSV module?
Kent Johnson
kent37 at tds.net
Sun Nov 21 03:45:13 CET 2004
Liam Clarke wrote:
> Kent,
>
> As always, you are a beam of light upon the darkness of my illogicity
> and/or ignorance.
Aw shucks...
>
> You're right, I wasn't reopening the inputfile after doing
> readlines(), which I was doing each time I opened the file! So, I
> guess there's a pointer for each file object, that readline
> increments.
Yes, an open file has a current position. f.readlines() reads until the
end of file and leaves the file position at the end. f.tell() tells you
the current position and f.seek() lets you set it. Unless you need the
raw line data from the file as well as the lists from csv.reader, the
simplest thing is just to get rid of the readlines().
Kent
More information about the Tutor
mailing list