reading the last line of a file
eurleif at ecritters.biz
Thu Sep 8 13:23:13 CEST 2005
Xah Lee wrote:
> i switched to system call with tail because originally i was using a
> pure Python solution
> inF = gzip.GzipFile(ff, 'rb');
> and since the log file is 100 megabytes it takes a long time and hogs
> massive memory.
inF = gzip.GzipFile(ff, 'rb')
for line in inF:
last_line = line
It's a bit slower than gzip and tail, but the memory usage is fine.
More information about the Python-list