fallenmonkey has asked for the wisdom of the Perl Monks concerning the following question:
Between each 1-to-n set of key/value pairs for a record, there is a single blank line. I'd like to turn this into a CSV file in the following format:<key 1> : <value 1> <key 2> : <value 2> .. <key n> : <value n>
What do you all think is the most logical/efficient way to do this? For now, the file is very predictable. The keys for every record are the same. However, this will likely be a long-term solution and I'd like it to be able to handle changes in the number or names of the keys without breaking. I'm considering reading the original file into hashes and arrays, and using the Text::CSV module to generate the output. Just figured I'd call upon the monastery to point out flaws in that plan before implementing it. Thank you all!"key 1","key 2", .. ,"key n" "value 1","value 2", .. ,"value n" <-- record 1 "value 1","value 2", .. ,"value n" <-- record 2 .. "value 1","value 2", .. ,"value n" <-- record n
The Fallen Monkey
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Record dump-style text --> CSV?
by Tanktalus (Canon) on Mar 09, 2005 at 22:36 UTC | |
by fallenmonkey (Initiate) on Mar 10, 2005 at 21:34 UTC |