perl - Parsing CSV with Text::CSV -
i trying parse file header row @ row 8. row 9-n data. how can use text::csv
this? having trouble, code below:
my @cols = @{$csv->getline($io, 8)}; $row = {}; $csv->bind_columns (\@{$row}{@cols}); while($csv->getline($io, 8)){ $ip_addr = $row->{'ip'}; }
use text::csv; $csv = text::csv->new( ) or die "cannot use csv: ".text::csv->error_diag (); open $io, "test.csv" or die "test.csv: $!"; $array_ref = $csv->getline_all($io, 8); $record = ""; foreach $record (@$array_ref) { print "$record->[0] \n"; } close $io or die "test.csv: $!";
Comments
Post a Comment