[Tutor] newbie string parsing question
clay at shirky.com
Thu Nov 13 17:07:23 EST 2003
Avoid re if you can
If you are parsing an apache error log, and you have python 2.2.2 or higher,
something like this might work:
for line in file("/usr/local/apache/var/log/error_log"):
line = line.strip()
line = line.replace("[", "")
fields = line.split("]") # needs 2.2.2 or higher
for entry in fields:
Fields is a list of date, error, client, and message.
> Hello all,
> I am new to the pyhon game and have been hitting a stone wall with the re
> module. I am trying to parse an app server log, in real time, and want return
> the whole string that contains a value, like "Error".
> Any help would be great....
> Tutor maillist - Tutor at python.org
More information about the Tutor