Parse ASCII log ; sort and keep most recent entries

Nova's Taylor novastaylor at hotmail.com
Wed Jun 16 17:06:10 EDT 2004


Hi folks,

I am a newbie to Python and am hoping that someone can get me started
on a log parser that I am trying to write.

The log is an ASCII file that contains a process identifier (PID),
username, date, and time field like this:

1234 williamstim 01AUG03 7:44:31               
2348 williamstim 02AUG03 14:11:20              
23 jonesjimbo 07AUG03 15:25:00                 
2348 williamstim 17AUG03 9:13:55               
748 jonesjimbo 13OCT03 14:10:05                
23 jonesjimbo 14OCT03 23:01:23                 
748 jonesjimbo 14OCT03 23:59:59  

I want to read in and sort the file so the new list only contains only
the most the most recent PID (PIDS get reused often). In my example,
the new list would be:

1234 williamstim 01AUG03 7:44:31               
2348 williamstim 17AUG03 9:13:55               
23 jonesjimbo 14OCT03 23:01:23                 
748 jonesjimbo 14OCT03 23:59:59  

So I need to sort by PID and date + time,then keep the most recent. 

Any help would be appreciated!

Taylor

NovasTaylor at hotmail.com



More information about the Python-list mailing list