in reply to Parsing a Log File

Start by defining what you want for output. I presume you want some kind of data structure? What would the data structure be for the snippet you provided? How about you modify the following to be what you want? Then we can help you write the parser. Or maybe you'll be able to do it on your own.

[ # First quarter [ 'ORL 13 Sauls kicked off 71 yards from the ORL30.', 'ASH 22 Noa returned the ball 14 yards to the ASH13. Tackled +by ORL 82 Ferguson.' ], 'Possession to Asheville.', [ # First dashes [ 10, 'ASH13', '14:30', [ 'ASH 48 Hopper ran around right end for 1 yard.', 'Tackled by ORL 94 Whiting, assisted by ORL 54 Schacht. +', ], ], [ 9, 'ASH14', '13:59', [ 'ASH 23 Theriot ran inside the left guard for 1 yard.', 'Tackled by ORL 96 Dugger.', ] ], [ 8, 'ASH15', '13:25', [ 'ASH 18 Hall pass completed to 23 Theriot for 10 yards. +', 'Tackled by ORL 96 Dugger.', ] ] ], [ # Second dashes [ 10, 'ASH25', '12:50', [ 'ASH 38 Dollinger ran around right end for 6 yards.', 'Tackled by ORL 95 Gonzalez, assisted by ORL 54 Schacht +.', 'Key block delivered by ASH 77 Cassell.', ] ], [ 4, 'ASH31', '12:05', [ 'ASH 18 Hall pass was overthrown, intended for 81 Perry +.', 'Penalty: ORL - Offsides.', ] ] ] ]

Keep in mind some of us (incl myself) don't know football.

Replies are listed 'Best First'.
Re^2: Parsing a Log File
by PrimeLord (Pilgrim) on Nov 29, 2004 at 19:24 UTC
    I am looking to produce a report that breaks down the statistics for the various players in different situations. For example lets say this snippet was the entire game. I need to know which quarter the events are taking place in which is clearly defined at the top of the file here. I am not concerned about the kick off action so the first line to parse would be:

    1-10-ASH13 (14:30) ASH 48 Hopper ran around right end for 1 yard. Tackled by ORL 94 Whiting, assisted by ORL 54 Schacht.


    That line says on 1st and 10 at the Ashveille 13 yard line 48 Hopper ran the ball 1 yard. Now in this game Aheville is the home team so I would essentially want take that information and put it into several "buckets" for the player 48 Hopper. So for example fomr this line we would add information into a "home game bucket" that said he ran once for 1 yard. We would also add that information into a bucket for the first quarter, first half, and 1st down.

    For simplicity sakes lets say the next line, which was also a run, was run by Hopper. Then I would just add that information into the home game, 1st quarter, and 1st half buckets, but would have to now drop the new information into a 2nd down bucket since it was on second down.

    Is that making it any clearer? I have to deal with penalties which can negate the previous play. The final report would look something like this.

    48 Hopper Situation Att Yards Total 2 2 Home 2 2 Away 0 0 1st Quarter 2 2 2nd Quarter 0 0 3rd Quarter 0 0 4th Quarter 0 0 1st down 1 1 2nd down 1 1 3rd down 0 0 4th down 0 0


    That is a pretty simplified version of what I am lookig for, but I hope that makes it a bit clearer.

    -Prime