Have few thousand reports that have consistently formatted tabular data embedded within them that I need to extract.
Have a few ideas, but thought I’d post to see if there’s a better way to do this than what I’m thinking; which is to extract the tabular data, create a new file for it, then parse that data as a tabular file.
Here’s a sample input and output, where the output read and written row by row to a database.
INPUT_FILE
MiscText MiscText MiscText
MiscText MiscText MiscText
MiscText MiscText MiscText
SubHeader
PASS 1283019238 alksdjalskdjl
FAIL 102310928301 kajdlkajsldkaj
PASS 102930192830 aoisdajsdoiaj
PASS 192830192301 jiasdojoasi
MiscText MiscText MiscText
MiscText MiscText MiscText
MiscText MiscText MiscText
OUTPUT (read/write row-by-row from text-file to DB)
ROW-01{column01,column02,column03}
...
ROW-nth{column01,column02,column03}
Recognizing when to start processing tabular data is easy. You’ve got the marker line. The difficulty is recognizing when to stop processing data. You can apply the heuristics of stopping to process data when the
splitdoesn’t yield the expected result.Save as
etd.pl(etd = extract tabular data, what did you think?), and call it like this from the command line: