space_cadet has asked for the wisdom of the Perl Monks concerning the following question:
I have some very large ugly data files with irregularly delimited (or non-delimited) elements. The files look like this:
After some manipulations I've been able to parse based onBob's Company VA chickens and cows April 23, 2003 2365 Elizabeth P. Jones Inc.WY widgets February 4, 2003 4 Big Huge CorporationUSAserversworkstationsrouters April 17, 2003 99999
I was wondering if anyone can think of a better way to do this. It took a great deal of work to reliably insert two or more whitespaces between valid data elements. Also, the files are quite large, and what if I wasn't assured of having a fixed number of elements?while (<READFILE>) { chomp; @columns = split/\s{2,}/g, $_, 7; }
Edit by tye, remove BR tags, use CODE tags so extra spaces are visible
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing irregularly delimited data
by Aragorn (Curate) on Apr 29, 2003 at 20:31 UTC | |
|
Re: Parsing irregularly delimited data
by cLive ;-) (Prior) on Apr 29, 2003 at 20:22 UTC | |
by space_cadet (Initiate) on Apr 29, 2003 at 20:54 UTC | |
|
Re: Parsing irregularly delimited data
by artist (Parson) on Apr 29, 2003 at 21:02 UTC | |
|
Re: Parsing irregularly delimited data
by graff (Chancellor) on Apr 30, 2003 at 04:00 UTC |