Subject: | selectall_csv_noheader() *includes* header row on Mac OS X 10.14.4 |
Date: | Thu, 28 Nov 2019 16:42:45 +0000 |
To: | "bug-DBIx-CSV [...] rt.cpan.org" <bug-DBIx-CSV [...] rt.cpan.org> |
From: | "Maeder, Stephen" <Stephen.Maeder [...] ingrammicro.com> |
Hi,
I discovered that selectall_csv_noheader() *includes* the header row on Mac OS X 10.14.4 - I am not sure if this is how it behaves on other platforms, too.
In other words, the output of selectall_csv and selectall_csv_noheader are identical. Here's a script to reproduce it:
#!/usr/bin/perl
my $sdm_port = 3409;
use DBI;
my $dbh = DBI->connect("dbi:mysql:database=default:host=127.0.0.1:port=$sdm_port", "", "", {RaiseError => 1, AutoCommit => 0, FetchHashKeyName => "NAME_lc"}) || die "DB open error: $DBI::errstr";
use DBIx::CSV;
my $query = "SELECT NOW() as 'The time is...';";
my $selectall_csv = $dbh->selectall_csv("$query");
my $selectall_csv_noheader = $dbh->selectall_csv_noheader("$query");
print "selectall_csv:\n$selectall_csv\n\n";
print "selectall_csv_noheader:\n$selectall_csv_noheader\n\n";
$dbh->disconnect();
__END__
Output of the above script for me:
selectall_csv:
"The time is..."
"2019-11-28 08:39:47"
selectall_csv_noheader:
"The time is..."
"2019-11-28 08:39:47"
I am presently working around this with:
my @lines= split(/\n/, $dbh->selectall_csv("$query")); # selectall_csv_noheader doesn't work on Mac OS apparently...
shift @lines; # So I just remove the header row here
open OUT, ">>$outputCSVfilename" or die $!;
print OUT join "\n", @lines;
close OUT;
—
Stephen Maeder
Senior Product Manager, Shipwire
Commerce & Lifecycle Services
[cid46cacb9e-d337-4753-9c83-73216e02971a]
If you do not wish to receive promotional materials from Ingram Micro via e-mail, please go to http://www.ingrammicro.com/emailmgmt or reply to this message and type unsubscribe in the subject.
Ingram Micro Inc.
Corporate Headquarters, 3351 Michelson Drive, Suite 100, Irvine, CA 92612
This email may contain material that is confidential, and proprietary to Ingram Micro, for the sole use of the intended recipient. Any review, reliance or distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
[Ingram_2818e5de]