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

Tim Chase python.list at tim.thechases.com
Sat Jan 29 14:13:37 EST 2011


On 01/26/2011 04:59 AM, 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...

I wrote a modestly tested version (including missing 
terminal-EOL, files with no newlines, and empty files) at

http://www.mail-archive.com/python-list@python.org/msg226537.html

which minimizes the number of seeks (reading chunks rather than 
seeking for every character as you work backwards).

You might find it useful.

-tkc






More information about the Python-list mailing list