Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^5: Descriptive Stats from .csv file

by Anonymous Monk
on Jan 31, 2014 at 22:54 UTC ( #1072923=note: print w/replies, xml ) Need Help??


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

Why am I getting undef after shotsky
$ cat melt.tsv Month Zone Replicate variable value Sept 1 1 SpeciesA 5 Sept 1 1 SpeciesB 10 Sept 1 1 SpeciesC 15 Sept 1 2 SpeciesA 0 Sept 1 2 SpeciesB 5 Sept 1 2 SpeciesC 10 Sept 1 3 SpeciesA 5 Sept 1 3 SpeciesB 0 Sept 1 3 SpeciesC 5 Sept 2 1 SpeciesA 5 Sept 2 1 SpeciesB 5 Sept 2 1 SpeciesC 5 Sept 2 2 SpeciesA 10 Sept 2 2 SpeciesB 15 Sept 2 2 SpeciesC 10 Sept 2 3 SpeciesA 0 Sept 2 3 SpeciesB 0 Sept 2 3 SpeciesC 5 $ cat melt.pl #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; use DBI; use DBD::CSV; my $dbh = DBI->connect( "dbi:CSV:", undef, undef, { RaiseError => 1 }, ); $dbh->{csv_tables}{melt} = { eol => "\n", sep_char => "\t", quote_char => undef, escape_char => undef, file => 'melt.tsv', col_names => [qw( Month Zone Replicate Species Specnum +)], }; my $names = $dbh->selectall_arrayref('SELECT DISTINCT species FROM mel +t'); dd( $names ); dd( shotsky => $dbh->selectall_arrayref(q{ select * from melt where Sp +ecies = ?}, { Slice => {} }, 'SpeciesB' ) ); for my $name ( @$names ){ dd( $name => $dbh->selectall_arrayref(' select Month, Zone, Species, AVG(Specnum) MEAN FROM melt WHERE melt.Species = ? ', { Slice => {} }, $name, ) ); } __END__ [["variable"], ["SpeciesA"], ["SpeciesB"], ["SpeciesC"]] ( "shotsky", [ { month => "Sept", replicate => 1, species => "SpeciesB", specnum => 10, zone => 1, }, { month => "Sept", replicate => 2, species => "SpeciesB", specnum +=> 5, zone => 1 }, { month => "Sept", replicate => 3, species => "SpeciesB", specnum +=> 0, zone => 1 }, { month => "Sept", replicate => 1, species => "SpeciesB", specnum +=> 5, zone => 2 }, { month => "Sept", replicate => 2, species => "SpeciesB", specnum => 15, zone => 2, }, { month => "Sept", replicate => 3, species => "SpeciesB", specnum +=> 0, zone => 2 }, ], ) ( ["variable"], [ { MEAN => undef, Month => undef, Species => undef, Zone => undef } +, ], ) ( ["SpeciesA"], [ { MEAN => undef, Month => undef, Species => undef, Zone => undef } +, ], ) ( ["SpeciesB"], [ { MEAN => undef, Month => undef, Species => undef, Zone => undef } +, ], ) ( ["SpeciesC"], [ { MEAN => undef, Month => undef, Species => undef, Zone => undef } +, ], )

Replies are listed 'Best First'.
Re^6: Descriptive Stats from <span style=
by Tux (Abbot) on Feb 01, 2014 at 08:06 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1072923]
help
Chatterbox?
and cookies bake in the oven...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-05-28 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?