Hi,

I have tried using DBD::CSV to query a csv-file. But I have a problem with 
handling numeric data. How can I modify the code below?

Thanks,
Michael

use DBI;
use Data::Dumper;

my $dbh_csv = DBI->connect ("dbi:CSV:", "", "", {
        f_dir => "csv",
        f_ext => ".csv/r",
        f_encoding => "utf8",
        
        csv_sep_char => ";",
        csv_eol => "\n",
        csv_quote_char => '"',
        csv_escape_char => '"',
        csv_class => "Text::CSV_XS",
        csv_null => 1,
        RaiseError => 1,
        });

$dbh_csv->{csv_tables}->{table_1} = {
    'file' => 'mmm.csv',
    'eol' => "\n",
};
$dbh_csv->{csv_tables}->{table_1}->{types} = [Text::CSV_XS::PV (), 
Text::CSV_XS::NV (), Text::CSV_XS::NV ()];

my $csv_select = "Select * From table_1 Where af1 < 1";

my $sth_csv = $dbh_csv->prepare($csv_select);
$sth_csv->execute;
my $rowxx = $sth_csv->fetchall_arrayref();
print Dumper $rowxx;

content table_1:

date;af1;vf1
2010-10-02;1,2;16,4
2010-10-03;1,4;18,4
2010-10-04;2,2;23,4
2010-10-02;0,2;34,7
...

Reply via email to