Anirban Adhikary wrote:
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

    my %cnt;
    /^"(\w+)"/ and $cnt{$1}++ while <>;
    print "col1 count\n";
    print "$_ -  $cnt{$_}\n" for sort keys %cnt;

and one more question how the null value will be handled

Are you expecting _us_ to know that??

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to