in reply to Re: perl group by and sort from a csv input file
in thread perl group by and sort from a csv input file

Then why not use DBD::CSV directly?

$ cat test.csv 3211111,100,3.2 3211112,101,3.2 3211111,100,1.2 3211112,100,2.2 3211113,100,5.2 3211112,100,0.3 $ cat test.pl use 5.18.2; use warnings; use DBI; use Text::CSV_XS qw(csv); my $dbh = DBI->connect ("dbi:CSV:"); $dbh->{csv_tables}{sampleData} = { file => "test.csv", col_names => [qw( sample input amount )], }; csv (in => $dbh->selectall_arrayref (" SELECT sample, input, SUM (amount) FROM sampleData GROUP BY sample, input ORDER BY sample, input")); $ perl test.pl 3211111,100,4.4 3211112,100,2.5 3211112,101,3.2 3211113,100,5.2

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^3: perl group by and sort from a csv input file
by Your Mother (Archbishop) on Jul 28, 2017 at 20:43 UTC

    Oh, I don't think a DB was necessary at all. But if you're going to use that idiom, it's better, I argue, to put it into a DB so you can use the DB tools. As I think I've said to you before, all ++s to you for your CVS CSV (update: DERPy fingers) related work. :P