Hi all,

I appear to have solved my problem with dealing with CSV files: here is my solution 
code:


#!/usr/local/bin/perl -w

use DBI;

($infile) = @ARGV;

my $dbh = DBI->connect("DBI:CSV:");
$dbh->{'csv_tables'}->{'weather'} =
  {
   'eol'       => "\n",
   'file'      => "$infile",
   'col_names' => ["DateTime", "MaxWSpd",
                                   "AvgWSpd",  "WindDir",
                                    "AirPres",     "RainBkt",
                                    "RelHumd",  "OutTemp",
                                    "InsTemp",  "MsrTemp",
                                    "FocTemp",  "XtrTemp"],
  };

$sth = $dbh->prepare("SELECT DateTime,MaxWSpd FROM weather WHERE MaxWSpd > 35");
$sth->execute;
while (@row = $sth->fetchrow) {
  print "@row\n";
}


Defining the columns did the trick.

Thanks for everyones help!

Regards,
    Stacy








Warren Pollans wrote:

> Stacy, Please let me know what the resolution to this problem is.  I haven't used 
>DBD::CSV yet, but I
> plan to start.  When I run your script I get the same results - no output.  Thanks, 
>Warren
>
> Stacy Mader wrote:
>
> > Even if I rename Date&Time to DateTime, my perl code does not
> > return any columns!
> >
> > Regards,
> >
> >         Stacy.
> >
> > On 18 Mar
> > 2001, Jeff Zucker wrote:
> >
> > > Stacy Mader wrote:
> > > >
> > > > 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
> > >
> > >
> > > The column name "Date&Time" is not a valid SQL column name.  Column
> > > names can not contain anything other than letters, numbers, and
> > > underscores.
> > >
> > > --
> > > Jeff
> > >

Reply via email to