loris has asked for the wisdom of the Perl Monks concerning the following question:
Hello all,
I have been given what seems to me a slightly hairy task. I have a report with fixed-width fields similar to this:
Line containing uninteresting information Another line containing uninteresting information More uninteresting information Transaction Employee --- Date Name Amount ------------ ------------------ 111/222/ABC 23-JAN-06 Baker, Abel 111.11 24-JAN-06 Baker, Abel 222.22 25-JAN-06 Baker, Abel 333.33 26-JAN-06 Baker, Abel 444.44 27-JAN-06 Baker, Abel 555.55 Line containing uninteresting information Another line containing uninteresting information Transaction Employee --- Date Name Amount ------------ ------------------ 333/444/DEF 23-JAN-06 Dog, 111.11 Charlie 24-JAN-06 Dog, 222.22 Charlie 25-JAN-06 Dog, 333.33 Charlie
Note the spurious ^L characters, which appear as boxes in my browser, at the beginning of some lines and the over-wide fields running into the following line.
This needs to be converted to Excel-readable format, e.g. CSV, containing the information from the table-like parts with information from the line after the headers in additional colums, like this:
Code1|Code2|Transaction Date|Employee Name|Amount 111|ABC|23-JAN-06|Baker, Abel|111.11 111|ABC|24-JAN-06|Baker, Abel|222.22 111|ABC|25-JAN-06|Baker, Abel|333.33 111|ABC|26-JAN-06|Baker, Abel|444.44 111|ABC|27-JAN-06|Baker, Abel|555.55 333|DEF|23-JAN-06|Dog, Charlie|111.11 333|DEF|24-JAN-06|Dog, Charlie|222.22 333|DEF|25-JAN-06|Dog, Charlie|333.33
I would approach this in the following way
Does any one have any less naive ideas? I wondered whether there is there something like format for reading files?
Thanks,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Converting a fixed-width report to an Excel-friendly format
by Corion (Patriarch) on Oct 25, 2006 at 16:00 UTC | |
by flake (Initiate) on Oct 26, 2006 at 17:30 UTC | |
Re: Converting a fixed-width report to an Excel-friendly format
by jZed (Prior) on Oct 25, 2006 at 16:04 UTC | |
Re: Converting a fixed-width report to an Excel-friendly format
by djp (Hermit) on Oct 26, 2006 at 04:18 UTC | |
Re: Converting a fixed-width report to an Excel-friendly format
by john_oshea (Priest) on Oct 25, 2006 at 18:14 UTC | |
Re: Converting a fixed-width report to an Excel-friendly format
by Anonymous Monk on Oct 25, 2006 at 20:06 UTC | |
by Anonymous Monk on Oct 25, 2006 at 20:08 UTC | |
Re: Converting a fixed-width report to an Excel-friendly format
by graff (Chancellor) on Oct 26, 2006 at 03:42 UTC |