Ron Savage wrote:
> 
> Stacy
> 
> DBI 1.14
> Text::CSV_XS 0.22
> SQL::Statement 0.1017
> DBD::CSV 0.1025
> 
> The latter 3 were installed a few minutes ago :-).
> 
> weather.dat:
> -----><8-----
> 
>Date&Time,MaxWSpd,AvgWSpd,WindDir,AirPres,RainBkt,RelHumd,OutTemp,InsTemp,MsrTemp,FocTemp,XtrTemp
> 26-DEC-1999 00:00:00,  -1,  -2,  -3,  -4,  -5,  -6, -7, -8, -9, -10, -11
> -----><8-----
> 
> I changed all the 9s so I could see which column was being returned.
> 
> x.pl:
> -----><8-----
> #!/usr/local/bin/perl -w
> use DBI;
> 
> $dbh = DBI->connect("DBI:CSV:f_dir=d:/temp") 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();
Hello All,

I was able to get the script to work by explicitly adding a record
separator ('^M' in vi) at the end of each line - didn't have to define
the column names.  I got here by creating a table and seeing what was in
it.  I had a large tab-delimited file (from star-office spreadsheet)
which for which Stacy's script produced the same no-output result -
adding '^M' to the end of each line fixed that problem.

Stacy, it may be that explicitly defining '\n' as your EOL char is what
fixed your problem.

Regards,

Warren


> 
> my($MaxWSpd, $WindDir, $AvgWSpd);
> 
> $sth->bind_columns(\$MaxWSpd, \$WindDir);
> 
> while ($sth->fetch) {
>   print("Found result row: $MaxWSpd, $WindDir \n");
> }
> 
> $sth->finish();
> $dbh->disconnect();
> -----><8-----
> 
> Same as yours.
> 
> Ouput:
> -----><8-----
> Found result row:   -1,   -3
> -----><8-----
> 
> Cheers
> Ron  Savage
> [EMAIL PROTECTED]
> http://savage.net.au/index.html

Reply via email to