We don't bite newbies here... much | |
PerlMonks |
Parsing CSV into a hashby McDarren (Abbot) |
on Sep 19, 2005 at 21:42 UTC ( [id://493311]=perlquestion: print w/replies, xml ) | Need Help?? |
McDarren has asked for the wisdom of the Perl Monks concerning the following question:
My first go at dealing with delimited data has not been as straightforward as I expected :( After stuffing around with various Text/CSV modules and super searching all over the place for an hour or two, I finally gave up and decided to write my own parsing routine. The data is tab delimited, with the first line being a header. Each column represents user attributes, and each row represents the data for a particular user. The only inconsistency in the data (if it is that), is that the header row has a leading hash (#), whereas the rest of the data doesn't. All I wanted to do is build a hash from the data, in the form $data->{$user}{$attribute} Although the code I have works, and is only about a dozen lines, I'm disappointed - because: a) I'm sure this could be done easier with the appropriate module - but I'm damned if I could work out how, and b) I've used both a flag and a counter, which I'm sure are redundant - but I don't know how to get rid of them Any advice? Thanks in advance --Darren
Back to
Seekers of Perl Wisdom
|
|