how to read the last line of a huge file???

MRAB python at mrabarnett.plus.com
Wed Jan 26 16:22:44 EST 2011


On 26/01/2011 10:59, Xavier Heruacles wrote:
> I have do some log processing which is usually huge. The length of each
> line is variable. How can I get the last line?? Don't tell me to use
> readlines or something like linecache...
>
Seek to somewhere near the end and then read use readlines(). If you
get fewer than 2 lines then you can't be sure that you have the entire
last line, so seek a little farther from the end and try again.



More information about the Python-list mailing list