Perl Monk, Perl Meditation | |
PerlMonks |
Re: Suggestions for simplifying script to parse csv databy radiantmatrix (Parson) |
on Jul 27, 2007 at 14:37 UTC ( [id://629113]=note: print w/replies, xml ) | Need Help?? |
As with most common tasks in Perl, someone has already written an excellent (and fast!) CSV parser and made it available via the CPAN as Text::CSV_XS. Using that module, it's easy to build a generic solution that parses each row of your CSV file into a hash using names provided on the first row:
At this point, @dataset is an array of hashes, where each hash represents a row in the database. From that general solution, you should be able to extrapolate your solution. For example, you can manipulate the data before pushing the row into the set, etc.
<–radiant.matrix–>
Ramblings and references The Code that can be seen is not the true Code I haven't found a problem yet that can't be solved by a well-placed trebuchet
In Section
Seekers of Perl Wisdom
|
|