I am trying to extract data from a CSV file using the code extract below, but it returns only four rows and they are all the same. If you point to what I am doing wrong or missing something that would be appreciated.
sample code:
The file test1.csv contains the following data:
I am running this on Windows XP platform.
Nasar
sample code:
Code:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my @row;
my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;");
my $sth = $dbh->prepare("SELECT * FROM test1.csv");
$sth->execute();
foreach (@row = $sth->fetchrow_array() ) {
print "Row: @row\n";
}
$sth->finish();
$dbh->disconnect();
The file test1.csv contains the following data:
Code:
"30360001","0","15","10"
"30360002","1","15","10"
"30360001","2","15","10"
"30360003","3","15","10"
"30360001","4","15","10"
"30360002","5","15","10"
I am running this on Windows XP platform.
Nasar