- or download this
use Text::CSV_XS qw( csv );
my $aoa = csv (in => "file.csv");
- or download this
my $aoa = csv (in => "file.csv", sep_char => ";");
- or download this
my $aoa = csv (in => "file.csv", sep => ";");
- or download this
use autodie;
use Text::CSV_XS;
...
# do something with the row
}
close $fh;
- or download this
# Default: return a list of lists (rows)
my $aoa = csv (in => "file.csv");
# Using the header line: return a list of hashes (records)
my $aoh = csv (in => "file.csv", headers => "auto");
- or download this
open my $fh, "<", "file.csv";
my @hdr = @{$csv->getline ($fh)};
$csv->column_names (@hdr);
while (my $row = $csv->getline_hr ($fh)) {
...
- or download this
open my $fh, "<", "file.csv";
my @hdr = @{$csv->getline ($fh)};
$csv->column_names (@hdr);
while (my $row = $csv->getline_hr ($fh)) {
- or download this
open my $fh, "<", "file.csv";
my @hdr = $csv->header ($fh);
$csv->column_names (@hdr);
while (my $row = $csv->getline_hr ($fh)) {
- or download this
sub Text::CSV_XS::header {
my ($csv, $fh, $seps) = @_;
...
close $h;
@{$row // []};
} # Text::CSV_XS::header
- or download this
=head2 $csv->header ($fh)
...
while (my $row = $csv->getline ($fh)) {
...
}
- or download this
#---
...
$csv->column_names ($csv->header ($fh, [ ";", ",", "|" ]));
while (my $row = $csv->getline_hr ($fh)) {
# $row = { foo => "1", bar => "baz" }