Read file from bottom

William Park opengeometry at NOSPAM.yahoo.ca
Mon May 13 16:40:20 EDT 2002


Julia Bell <julia.bell at jpl.nasa.gov> wrote:
> I'm currently using
>    line = input_handle.readline()
> to read individual lines from an input file; however, I'm only generally
> interested in the last few lines of the line (not the preceeding several
> thousand lines).
> 
> Is there an efficient (and relatively easy - I'm new to Python) way of
> reading the file from the last line backward instead of the first line
> forward?
> 
> (I do not want to read the entire file using readlines because it could
> overwhelm the memory.)

tail | python script.py 

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin



More information about the Python-list mailing list