A few beginning questions
richardc
richardc at hmgcc.gov.uk
Tue Jul 15 08:41:23 EDT 2003
"Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message
SNIP
> If the file isn't too large you can call the readlines() method and simply
> reverse the result as above. You may find this incovenient for very large
> files though.
It may well be
> I can't think of many cases where I would want to read a
> whole file in reverse, if all you want is the last few lines of a massive
> file then just seek near the end before reading the remainder and reverse
> the resulting list of lines.
This is exactly what Im doing, what Im actually doing is seeking to 1024
bytes from the end, then looking for the string
'startref\r\n<number>\r\n%%EOF' where <number> is an integer in decimal
format
I wanted to scan the lines backwards until I found %%EOF (as its likley to
be the last line) and do it that way. I might do that or might use a regex
and just let that find it.
Cheers
Rich
More information about the Python-list
mailing list