in reply to Counting items in a CSV

For a large number of columns in a tab-delimited or a csv file, its quite easy to use existing modules to get the information you want. If files are nicely structured, regardless of the number of columns, you can use the Data::CTable module. When combined with the Statistics::Descriptive module, you can get much more information from your data... the let's say your data is like this...
name,date,size name1,date1,120 name2,date2,140 name3,date3,150
well here's some code, hopefully easy enough to understand...
use strict; use Data::CTable; use Statistics::Descriptive; my $data = Data::CTable->new("data.txt"); # your csv file $data->clean_ws(); # clean up whitespace my $sizecolumn = $data->col('size'); # get column by name my $stat = Statistics::Descriptive::Full->new(); $stat->add_data($sizecolumn); print "sum of the column size:", $stat->sum() , "\n";
Its up to you, you can use the Statistics::Descriptive module to get much more information (sum, mean, median standard deviation etc) from your data as well, or maybe if you just need a simple sum you can add the elements of the array yourself.

perliff

----------------------

-with perl on my side