|Think about Loose Coupling|
Re: Parsing a log fileby reasonablekeith (Deacon)
|on Nov 27, 2007 at 17:13 UTC||Need Help??|
Your data seems a bit too ambiguous to parse easily. You can't, as in your example, just split on white space, as your 'msg' data field is an unquoted string (so you'll get a seperate field for each word in the string). Your best option is to get the log file tab delimited (I'm guessing it isn't at the moment), and stop reading this post.
However, if you don't have control of the data, you'll just have to take a stab. With the assumption that the first four fileds don't have spaces in them, and that the key/value data that follows doesn't have any '='s in the data, then you could do something like this...
... which works by pulling off the easy four first fields, and then works from the end of the rest of the data, creating a key pair hash.
It's pretty ugly, but with your data, I don't see a way around it.
my name's not Keith, and I'm not reasonable.