go to specific line in text file

Jonathan Gardner jgardner at jonathangardner.net
Wed Jun 18 11:55:23 EDT 2008


On Jun 17, 3:10 am, Patrick David <patrick.da... at tu-clausthal.de>
wrote:
>
> I am searching for a way to jump to a specific line in a text file, let's
> say to line no. 9000.
> Is there any method like file.seek() which leads me to a given line instead
> of a given byte?
>

As others have said, no. But if you're wondering how other file
formats do this, like BDB or PostgreSQL data files, which absolutely
have to jump to the magical spot in the file where the data is, they
keep an index at the beginning of the file that points to what byte
the data they are looking for is in.

So if it's really important to be able to do this, consider that.




More information about the Python-list mailing list