reading specific lines of a file

Piet van Oostrum piet at cs.uu.nl
Sat Jul 15 16:30:48 EDT 2006


>>>>> Yi Xing <yxing at stanford.edu> (YX) wrote:

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

Not fast. You have to read all preceding lines.
If you have to do this many times while the file does not change, you could
build an index into the file.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list