Subject: | DBD::CSV skips first row of file even when col_names is given |
DBD::CSV is skipping the first row of the file, even when I set col_names attribute to []. I
expected the first row to be included since the file does not have a header row and I set
col_names.
I attached a test case that demonstrates the issue.
Subject: | dont_skip_first_row.t |
#!/usr/bin/env perl
use Test::Simple tests=>1;
use DBI;
use File::Temp;
use File::Basename qw(basename);
use DBD::CSV;
use Text::CSV;
use strict;
use warnings;
my $tmp = File::Temp->new(DIR=>'.');
$tmp->unlink_on_destroy(1);
print $tmp "$_\n" for 1..5;
close $tmp;
my %tab=(sep_char=>"\t",quote_char=>undef,escape_char=>"\\",allow_loose_escapes=>1);
my $dbh = DBI->connect("dbi:CSV:", undef, undef, {
RaiseError=>1,
PrintError=>1,
map { ("csv_$_"=>$tab{$_}) } keys %tab,
});
my $sth = $dbh->prepare("select * from ".basename($tmp->filename));
$dbh->{csv_tables}{seq}{col_names} = [];
$sth->execute;
my $ctr = 0;
while (my $row=$sth->fetchrow_arrayref) {
$ctr++;
}
ok($ctr == 5);