Files, Seek, and Readlines. A newbie question
Bengt Richter
bokr at oz.net
Mon Apr 1 17:03:58 EST 2002
On Mon, 01 Apr 2002 15:58:43 GMT, "John Purser" <NO_SPAM_jmpurser2 at attbi.com> wrote:
>Hello,
>
>I'm using a large (>120,000 lines) sorted ASCII text file as an index. I
>started running into problems as soon as I began to use the .seek() to
>position before a read. Even when not opened as a binary file seek moves by
>bytes not lines. Is there a line oriented seek version? Is there a better
>way to get to line 50 than:
>myFile.seek(0)
>myFile.readlines(49)
>Record = myFile.readline()
>?
>
I recently posted a class definition that would create an index
of line positions so that later you could access the lines randomly.
See post titled "Re: seek in a file"
Email me if you don't find it. But I'll be gone a couple of days.
Regards,
Bengt Richter
More information about the Python-list
mailing list