Text::CSV::Slurp - convert CSV into an array of hashes
I often need to take a CSV file that has a header row and turn it into a perl data structure for further manipulation. This package does that in as few steps as possible.
use Text::CSV::Slurp; my $data = Text::CSV::Slurp->load(file => $filename [,%options]); my $data = Text::CSV::Slurp->load(filehandle => $filehandle [,%options]); my $data = Text::CSV::Slurp->load(string => $string [,%options]);
Returns an array of hashes. Any extra arguments are passed to Text::CSV. The first line of the CSV is assumed to be a header row. Its fields are used as the keys for each of the hashes.
my $slurp = Text::CSV::Slurp->new();
Instantiate an object.
my $data = Text::CSV::Slurp->load(file => $filename); my $data = $slurp->load(file => $filename);
Load some CSV from a file, filehandle or string and return an array of hashes
Text::CSV
IO::Handle
Test::Most - for tests only
GNU General Public License v3
Available at http://code.google.com/p/perl-text-csv-slurp/
Spreadsheet::Read
To install Text::CSV::Slurp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::CSV::Slurp
CPAN shell
perl -MCPAN -e shell install Text::CSV::Slurp
For more information on module installation, please visit the detailed CPAN module installation guide.