Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^4: Descriptive Stats from .csv file

by Tux (Abbot)
on Jan 31, 2014 at 14:09 UTC ( #1072849=note: print w/replies, xml ) Need Help??

in reply to Re^3: Descriptive Stats from .csv file
in thread Descriptive Stats from .csv file

Without even trying to understand what was required, a lot is already possible with DBD::CSV.

$ cat pm1072615.csv Month,Zone,Replicate,SpeciesA,SpeciesB,SpeciesC Sept,1,1,5,10,15 Sept,1,2,0,5,10 Sept,1,3,5,0,5 Sept,2,1,5,5,5 Sept,2,2,10,15,10 Sept,2,3,0,0,5 $ cat #!/usr/bin/perl use 5.14.2; use warnings; use DBI; my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_ext => ".csv/r", }); my $sth = $dbh->prepare (qq; select month, zone, replicate, avg (speciesa) from pm1072615 group by month,zone, replicate; ); $sth->execute; while (my $row = $sth->fetch) { printf "%-5s %3d %3d %8.5f\n", @$row; } $ perl Sept 2 1 5.00000 Sept 2 2 10.00000 Sept 1 1 5.00000 Sept 1 3 5.00000 Use of uninitialized value in printf at line 19. Sept 1 2 0.00000 Use of uninitialized value in printf at line 19. Sept 2 3 0.00000 $

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^5: Descriptive Stats from .csv file
by Anonymous Monk on Jan 31, 2014 at 22:54 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072849]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2016-10-24 12:02 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (305 votes). Check out past polls.