hi123 has asked for the wisdom of the Perl Monks concerning the following question:
I have a csv file xyz.csv with contents
name,age,place,phone
xyz,12,ohio,7372829
sed,23,hrh,9890908
I need to parse the csv file and check whether it is a empty file ie it doesnt have the values for the headers provided
a null file xyz.csv would contain just the headers (headers no may decrease or increase) eg :
name,age,place,phone
name,age,place,mob,phno,ht
how do i check for a null file in below code and print whtr null or not?
i have developed below script to parse the csv
please advise...open(my $data, '<', $file_c) or die "Could not open '$file_c' $!\n +"; while (my $line = <$data>) { next if ($. == 1); chomp $line; my @fields = split "," , $line; print"$fields[0] fields[1]"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How check whether csv file with header is empty file or not in perl
by bart (Canon) on Sep 06, 2012 at 10:26 UTC | |
by Tux (Canon) on Sep 06, 2012 at 14:03 UTC | |
by hi123 (Initiate) on Sep 06, 2012 at 10:44 UTC | |
Re: How check whether csv file with header is empty file or not in perl
by CountZero (Bishop) on Sep 06, 2012 at 10:19 UTC | |
by hi123 (Initiate) on Sep 06, 2012 at 11:07 UTC | |
by CountZero (Bishop) on Sep 06, 2012 at 14:42 UTC |
Back to
Seekers of Perl Wisdom