Re: csv file question

[email protected] ("perl pra")
Newsgroups perl.beginners
Message-ID <[email protected]>
Hi

please check the following script , you need not to handle null because it
is in quotes,I have tested the following code it works fine



use strict;
use warnings;


my %has;
my $NULL=0;
(open my $FH, '<', "mail.csv") or die "$!";

while(<$FH>)
{

my($one,$two,$three)=split(/\,/,$_);

$has{$one}++;

}
foreach my $key (keys %has)
{
 print "$key is $has{$key} times\n";
}



On 5/6/08, Anirban Adhikary <[email protected]> wrote:
>
> Dear list
> I have a csv file having the following contents.
> col1 col2 col3
> "A", "1","2"
> "B","1",   "3"
> "C","2","4"
> "D","1","5"
> "A","1","6"
> "B","2","7"
> "C","2","8"
> " ","3","9"
>
> Now I want to implement a logic which will show me the summarize records
> as
> follows
> col1 count
> A-   2
> B -  2
> C -  2
> D -  1
>
> and one more question how the null value will be handled
>
> Thanks & Regards
> Anirban Adhikary.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.