Dear Monks,
I have a daily log file with tens of millions of records like:
======================================================================
Record: 9868943 Version: 2 Timestamp: Sat Feb 18 22:33:43 2006
Primary (Reporting) ID: 240 Level: 2 Group: 1 Reg: no Event: 51748
Keep: 1 ID-Node: 0x2017 Inverse: 25
Secondary ID:
Keep: 1 ID: 68 Inverse: 23
Keep: 1 ID: 240 Inverse: 27
Keep: 1 ID: 368 Inverse: 30
======================================================================
Record: 9868944 Version: 2 Timestamp: Sat Feb 18 22:33:44 2006
Primary (Reporting) ID: 67 Level: 9 Group: 0 Reg: no Event: 51749
Keep: 1 ID-Node: 0xA087 Inverse: 55
Secondary ID:
Keep: 1 ID: 62 Inverse: 73
======================================================================
+=
I need to get the "Primary (Reporting) ID", "Level", "Group", "ID-Node", and "Inverse" values. I also need to get n-to-4 of the "Secondary ID" fields stripped out of each record which I will then insert into a DB.
I thought about using a regexp to replace all spaces with a comma and the "===" lines with a "\n" and write it to a temp file.
Then I'd iterate line by line over the temp file splitting the CSV string into an array and then get my data elements like that. Similar to what I saw at
Parsing multi-line recordsDoes that sound like a good start or should I be trying another method?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.