Re^3: Reading tab/whitespace delimited text fileby BrowserUk (Pope)
|on Oct 22, 2012 at 06:31 UTC||Need Help??|
Yuck! I thought (hoped) that this type of file format -- mixed, fixed-format records -- had died long ago; but they seem to keep reinventing it :)
For your first example, the trick is to define a regex that will match the fields in the header line:
and use that to construct an unpack template to parse the following values line.
This is not 'nice code', but it demostrates the technique:
Extending that to apply it to all your other sections will require a little ingenuity and a lot of painstaking testing.
I do hope for your sake that the number and ordering of the different sections is well-defined, else you've got an even worse task on your hands.
Note:This assumes that field names do not contain spaces. If they do, you are in shit street.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.