hello, monks
I got a weird problem when using Text::CSV to process a list of 119880 records/lines saved in in.csv, the code I am using is as follows:
#!/usr/bin/perl use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new({ binary => 1, allow_whitespace => 1, allow_loose_quotes => 1, }) or die Text::CSV->error_diag (); open my $csvfile, '<', 'in.csv' or die "cannot open in.csv for reading +: $!"; open my $fout, '>', 'out.txt' or die "cannot open out.txt for writting +: $!"; my $line_no = 0; while (my $record = $csv->getline($csvfile)) { $line_no++; my $value = "$record->[9], $record->[7], $record->[8] $record->[1 +0]"; printf {$fout} "[%06d] %s\n", $line_no, $value; } __END__
By running this code, I got only 119606 records in out.txt.. so how can I detect the 274 missing records. or are there any robust ways to grab records from a CSV file and process its fields within a while loop.
BTW. I used wc -l filename to count the number of lines contained in filename.
Thanks
lihao
In reply to A problem with Text::CSV by lihao
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |