reading specific lines of a file

Simon Forman rogue_pedro at yahoo.com
Sat Jul 15 18:23:37 EDT 2006


Yi Xing wrote:
> Hi All,
>
> I want to read specific lines of a huge txt file (I know the line #).
> Each line might have different sizes. Is there a convenient and fast
> way of doing this in Python? Thanks.
>
> Yi Xing

I once had to do a lot of random access of lines in a multi gigabyte
log file.  I found that a very fast way to do this was to build an
index file containing the int offset in bytes of each line in the log
file.

I could post the code if you're interested.

Peace,
~Simon




More information about the Python-list mailing list