[Tutor] Trying to extract the last line of a text file

Luke Paireepinart rabidpoobear at gmail.com
Fri Oct 20 04:42:22 CEST 2006


Chris Hengge wrote:
> More on that.. some of the file I work with are thousands of lines 
> long... one is even 10's of thousands.. so reading the entire thing 
> into ram is MUCH faster then reading line by line with the filestream 
> open. 
Did you look at my code?
It doesn't read the whole thing into ram, nor does it read line by line.
It seeks to the end of the file (should be extremely fast)
and reads backwards until it gets to a newline char.
In other words: Very fast, and no extra ram usage.
HTH,
-Luke


More information about the Tutor mailing list