Re: Parsing a odd log file format
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Tue, 20 Feb 2007 00:52:56 +0100
"robi" <robisen@xxxxxxxxx> writes:
That looks fantastic and I will most likely use that but I would still
like to understand how to deal with the part of my log file that is
not quoted, does not have a comma, etc for my own edification. Part
of my goal is to understand the language not just parse logs :-)
This is a general problem, that you have solved yourself at least
once, so you should be able to solve it again, of learning the grammar
of an unknown language. You did it when you learned English, perhaps
as a baby. Why couldn't you do it again now?
You could use one of the learning algorithms you can find in AI books
or paper to automatically find a grammar to parse these files, but
since it looks so simple, here is how you can do it:
Parse all the lines as csv, and the ones where you don't have the
expected count of fields, you consider they're stack frames. You can
collect sequences of stack frames and attach them to the previous (or
following csv line).
So the grammar is:
<file> ::= | <entry> <file> .
<entry> ::= <csv> <frames> .
<frames> ::= | <frame> <frames> .
<csv> ::= <field> "," <field> "," <field> "," <field> "," <field> .
-- for example, if the csv records have 5 fields.
<frame> ::= <any line that is not a csv line> .
--
__Pascal Bourguignon__ http://www.informatimago.com/
You're always typing.
Well, let's see you ignore my
sitting on your hands.
.
- Follow-Ups:
- Re: Parsing a odd log file format
- From: robi
- Re: Parsing a odd log file format
- References:
- Parsing a odd log file format
- From: robi
- Re: Parsing a odd log file format
- From: nhabedi
- Re: Parsing a odd log file format
- From: robi
- Parsing a odd log file format
- Prev by Date: Re: using a macro to modify an object every time some funciton is called
- Next by Date: Re: vi as a lisp editor vs emacs
- Previous by thread: Re: Parsing a odd log file format
- Next by thread: Re: Parsing a odd log file format
- Index(es):
Relevant Pages
|