Hi all,

In a file called weather (in /tmp/weather_db) I have some date files in
the following format:


Date&Time,MaxWSpd,AvgWSpd,WindDir,AirPres,RainBkt,RelHumd,OutTemp,InsTemp,MsrTemp,FocTemp,XtrTemp

26-DEC-1999 00:00:00,  -9999,  -9999,  -9999,  -9999,  -9999,  -9999,
-9999.0, -9999.0, -9999.0, -9999.0, -9999.0
.
.
.

An ideal choice for DBD::CSV? In trying to access such files with
DBD::CSV, I an getting nothing returned. My code with perl is:

#!/usr/local/bin/perl -w
use DBI;
DBI->trace( 1, 'report.log' );

$dbh = DBI->connect("DBI:CSV:f_dir=/tmp/weather_db")
  or die "Cannot connect: " . $DBI::errstr;
$dbh->{'csv_tables'}->{'weather'} = { 'file' => 'weather'};
my $sql = "SELECT MaxWSpd, WindDir FROM weather WHERE  AvgWSpd < 10.00";

my $sth = $dbh->prepare($sql)
  or die "Cannot prepare: " . $dbh->errstr();

$sth->execute() or die "Cannot execute: " . $sth->errstr();

my($MaxWSpd, $WindDir, $AvgWSpd);

$sth->bind_columns(\$MaxWSpd, \$WindDir);

while ($sth->fetch) {
  print("Found result row: $MaxWSpd, $WindDir \n");
}

$sth->finish();
$dbh->disconnect();


Now since I have set DBI to trace, the output from that is:

    DBI 1.14-nothread dispatch trace level set to 1
    -> DBI->connect(DBI:CSV:f_dir=/p/smader/weather/db, , ****)
    -> DBI->install_driver(CSV) for perl=5.006 pid=17890 ruid=1017
euid=1017
       install_driver: DBD::CSV loaded (version 0.1021)
    <- install_driver= DBI::dr=HASH(0x198aa4)
    <- default_user= ( undef undef ) [2 items] at DBI.pm line 405.
    <- STORE('f_dir' '.' ...)= 1 at File.pm line 96.
    <- STORE('f_dir' '/p/smader/weather/db' ...)= 1 at File.pm line 107.

    <- FETCH= undef at CSV.pm line 78.
    <- STORE('csv_tables' HASH(0x1d5184) ...)= 1 at CSV.pm line 78.
    <- connect= DBI::db=HASH(0x1791fc) at DBI.pm line 408.
    <- STORE('PrintError' 1 ...)= 1 at DBI.pm line 433.
    <- STORE('AutoCommit' 1 ...)= 1 at DBI.pm line 433.
    <- connect= DBI::db=HASH(0x1791fc)
    <- FETCH= HASH(0x1d5184)0keys ('csv_tables' from cache) at csv.pl
line 7.
    <- FETCH= 'DBD::CSV::st' ('ImplementorClass' from cache) at File.pm
line 164
.
    <- STORE('f_stmt' DBD::CSV::Statement=HASH(0x295720) ...)= 1 at
File.pm line
 171.
    <- STORE('f_params' ARRAY(0x295774) ...)= 1 at File.pm line 172.
    <- STORE('NUM_OF_PARAMS' 0 ...)= 1 at File.pm line 173.
    <- prepare('SELECT MaxWSpd, WindDir FROM weather WHERE  AvgWSpd >
10.00' COD
E)= DBI::st=HASH(0x2955c4) at csv.pl line 10.
2   <- FETCH= 0 at File.pm line 371.
2   <- STORE('NUM_OF_FIELDS' 2 ...)= 1 at File.pm line 371.
    <- execute(CODE)= '0E0' at csv.pl line 13.
    <- bind_columns= 1 at csv.pl line 17.
    <- fetch= undef at csv.pl line 19.
    <- finish= 1 at csv.pl line 23.
    <- disconnect= 1 at csv.pl line 24.
    <- DESTROY= undef at unknown location!
    <- disconnect_all= undef at DBI.pm line 450.
    <- DESTROY= undef during global destruction.
    <- DESTROY= undef during global destruction.


Can anyone help me out here? Why is nothing being returned?

Reply via email to