Creating a dictionary from log file records
Roy.Culley at switzerland.org
Roy.Culley at switzerland.org
Fri Feb 16 10:45:04 EST 2001
I'm new to python and am trying to convert a perl script which analyses
firewall logs to python as a learning exercise.
The log files contain lines of multiple key / value pairs such as:
interface qfe0 proto tcp src 1.1.1.1 dst 2.2.2.2 service smtp \
s_port 44008 len 44 rule 7
Not all records are the same and the key / value pairs are not at
fixed positions. In perl, assuming the line is in $_, I can do:
%Rec = split
Is there an equivalent simple way to do this with python? I've done
it by converting the data into a list and using a while loop to set
the dictionary entries. However, the log files have about 4 million
entries per day so I need something that is fast.
Any help / suggestions most appreciated.
More information about the Python-list
mailing list