Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: csv file qu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 4 Topic 11031 of 11518
Post > Topic >>

Re: csv file question

by perlpra@[EMAIL PROTECTED] (Perl Pra) May 10, 2008 at 11:46 AM

------=_Part_2_8333741.1210400196534
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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 <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.
>

------=_Part_2_8333741.1210400196534--
 




 4 Posts in Topic:
csv file question
anirban.adhikary@[EMAIL P  2008-05-06 14:41:14 
Re: csv file question
yitzle@[EMAIL PROTECTED]   2008-05-06 10:37:13 
Re: csv file question
noreply@[EMAIL PROTECTED]  2008-05-06 19:37:07 
Re: csv file question
perlpra@[EMAIL PROTECTED]  2008-05-10 11:46:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 13:06:33 CDT 2008.