File Reading , Reverse Direction
Scott David Daniels
Scott.Daniels at Acm.Org
Fri Jul 27 03:01:32 EDT 2001
Reading backwards is tough, but reading forwards from a guaranteed
conservative guess is pretty easy:
file.seek(-2*MAX_LINE, 2)
lines = file.readlines()[-2:]
"Ratnakar Malla" <rmalla1 at lsu.edu> wrote in message
news:3B60F7EC.5275E026 at lsu.edu...
> I need to read from ... [the] 2 lines at the bottom of ... [a very long]
file.
> 1) Can i read the file in the reverse direction , so that I dont lose
> time?
> 2) If so how??
-Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list