Sorting Apache Log Files

Sheila King sheila at spamcop.net
Mon Jun 18 19:26:50 EDT 2001


On 18 Jun 2001 15:55:53 -0700, lenny.self at qsent.com (Lenny) wrote in
comp.lang.python in article
<b1aa9ab6.0106181455.681ef924 at posting.google.com>:

: I was planning on loading each of the log files
:into a list and then sorting the list.  Unfortualy, I am unaware of
:how to do that when the value I wish to search on isn't at the
:beginning of the line.  I need to search on Apache's date string.

How about this? Create a list of tuples, where the tuple is:

(datestamp, full_line)

So, as you put each line from the log into the list, grab the datestamp
from the line, make a tuple and then sort the list on the first element
of each tuple?

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/





More information about the Python-list mailing list