Reading just a few lines from a text file
rafi
rafi at free.fr
Tue Aug 23 17:49:32 EDT 2005
tkpmep at hotmail.com wrote:
> I have a text file with many hundreds of lines of data. The data of
> interest to me, however, resides at the bottom of the file, in the last
> 20 lines. Right now, I read the entire file and discard the stuff I
> don't need. I'd like to speed up my program by reading only the last 20
> lines. How do I do this?
>
> Thomas Philips
>
If you are using a Unix:
tail -20 file.txt
--
rafi
"Imagination is more important than knowledge."
(Albert Einstein)
More information about the Python-list
mailing list