finding last match in a file

Mark McEahern marklists at mceahern.com
Thu Sep 19 14:00:52 EDT 2002


> I have a number of very large files where I have to find the last line
> which matches a certain experssion.  Currently I'm simply opening the
> file and looping through it noteing each time a line matches and at the
> end of the loop I see which was the last match.  However this is very
> slow and inefficient.  Is there some way to read through the file
> backwards and simply find first match starting from the end of the file.
> The files are really too big to read the entire thing into memory.

Well this is worth considering:


http://groups.google.com/groups?selm=000101bd9b36%2405590020%2451a22299%40ti
m

// m

-





More information about the Python-list mailing list