[Tutor] How to parse and extract data from a log file?

2007-08-07 Thread Tim Finley
I'm a newbie to programming and am trying to learn Python.  Maybe I'm wrong, 
but I thought a practical way of learning it would be to create a script.  I 
want to automate the gathering of mailbox statistics for users in a post 
office.  There are two lines containing this information for each user.  I 
want to find the two lines for each user and place the information in a 
different file.  I can't figure out how to find the information I'm after.  
Can you provide me an example or refer me to some place that has it?


_
Messenger Café — open for fun 24/7. Hot games, cool activities served daily. 
Visit now. http://cafemessenger.com?ocid=TXT_TAGHM_AugHMtagline


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Trouble with script not parsing out text

2007-08-29 Thread Tim Finley


I get the following when running a script.
 
TypeError: argument 1 must be string or read-only character buffer, not _sre.SRE_Pattern
 
Here is the script I am trying to run.   I am trying to verify that my search is returning what I am trying to search for, but due to the error I can verify it.
 
import re
 
log = open('audit.log') # Opens audit loglog2 = open('timaudit.log','w')for line in log:    line =re.compile(r"""    \w  #match any alphanumeric character    \Audit report for user+    \User reported as inactive+    """, re.VERBOSE)    line.search('Audit report for user () User reported as inactive')    log2.write(line)
 
log.close()
log2.close()
 
Thank you,
 
Tim FinleyNovell IT Services EngineerNovell Technical ServicesNovell

timaudit.log
Description: Binary data
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor