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 } +, ], )

In reply to Re^5: Descriptive Stats from .csv file by Anonymous Monk
in thread Descriptive Stats from .csv file by korsmo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.