DBD::CSV with column names containing spaces 
Author Message
 DBD::CSV with column names containing spaces

With a csv file that looks like

Order ID,Product ID,Description
7808,14008,Star Wars Edition 1
7009,15002,Sorry

I am unable to do a select on the Order ID column where the Order ID is 7808

#!/usr/bin/perl

use DBI;

my $dbh = DBI->connect("DBI:CSV:f_dir=.") or die "Can't connet";
$dbh->{csv_tables}->{generic} = { eol => "\n", file => 'generic.csv'};

my $query = qq[SELECT * FROM generic where 'Order ID' == 7808];
my $sth = $dbh->prepare($query);
$sth->execute();

while ( my ($row) = $sth->fetchrow_hashref )
{
 last unless ( $row );
 foreach my $keyval ( keys %{ $row } )
 {
  print "$keyval: $row->{$keyval}\n";
 }

Quote:
}

$sth->finish;


Tue, 05 Feb 2002 03:00:00 GMT  
 DBD::CSV with column names containing spaces

Quote:

> With a csv file that looks like

> Order ID,Product ID,Description

do spaces in column names not cause problems, even with csv?
just a thought.

Quote:
> 7808,14008,Star Wars Edition 1
> 7009,15002,Sorry

> I am unable to do a select on the Order ID column where the Order ID is 7808

> #!/usr/bin/perl

> use DBI;

> my $dbh = DBI->connect("DBI:CSV:f_dir=.") or die "Can't connet";
> $dbh->{csv_tables}->{generic} = { eol => "\n", file => 'generic.csv'};

> my $query = qq[SELECT * FROM generic where 'Order ID' == 7808];

if csv uses 'proper' sql then the line above should be =

Any help at all?

Richard H



Tue, 05 Feb 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HTTP::Daemon doesn't handle file names containing spaces

2. Getting DBD::CSV to write the collumn names as first line of file

3. DBD::CSV can't find IO::File->new(name, mode)

4. DBD::CSV or TEXT::CSV

5. DBD::CSV creates tables with column names in upper case..

6. Which is broken DBD::Proxy or DBD::CSV

7. Reference to columns in a huge CSV file

8. extracting columns from sar into a csv...

9. Name space switching using variable package names

10. input may not contain consecutive spaces.

11. Filenames containing spaces

 

 
Powered by phpBB® Forum Software