in reply to How check whether csv file with header is empty file or not in perl
open(my $data, '<', $file_c) or die "Could not open '$file_c' $!\n"; my $rows = 0; while (my $line = <$data>) { next if ($. == 1); chomp $line; my @fields = split "," , $line or next; $rows++; print"$fields[0] fields[1]"; } print "Total: $rows rows.\n" if $rows; print "No rows were found.n" unless $rows;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How check whether csv file with header is empty file or not in perl
by Tux (Canon) on Sep 06, 2012 at 14:03 UTC | |
|
Re^2: How check whether csv file with header is empty file or not in perl
by hi123 (Initiate) on Sep 06, 2012 at 10:44 UTC |