go to specific line in text file
Larry Bates
larry.bates at websafe.com`
Wed Jun 18 11:26:48 EDT 2008
Patrick David wrote:
> Hello NG,
>
> 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?
>
> Hope for help
> Patrick
Others have given the general answer (No), but if you are lucky enough to have
FIXED length lines you can jump by just calculating the byte offset of the
beginning character in line 9000 by using file.seek() and then read the bytes.
You didn't say anything about the format of the file.
-Larry
More information about the Python-list
mailing list