在这个脚本中,如果我使用/ home/mm/test_x,文件名为/ home/mm/test_x,那么文件名扩展名有问题: 的.csv它并不:DBD :: CSV:文件扩展名存在问题
DBD::CSV::st execute failed:
Execution ERROR: No such column '"/home/mm/test_1.csv".id' called from /usr/local/lib/perl5/site_perl/5.12.0/x86_64-linux/DBD/File.pm at 570.
输出没有文件名扩展:
'1', 'Brown', 'Laramie'
'2', 'Smith', 'Watertown'
2 rows
#!/usr/bin/env perl
use warnings; use strict;
use 5.012;
use DBI;
my $table_1 = '/home/mm/test_1.csv';
my $table_2 = '/home/mm/test_2.csv';
#$table_1 = '/home/mm/test_1';
#$table_2 = '/home/mm/test_2';
my $dbh = DBI->connect("DBI:CSV:");
$dbh->{RaiseError} = 1;
$table_1 = $dbh->quote_identifier($table_1);
$table_2 = $dbh->quote_identifier($table_2);
my $sth = $dbh->prepare("SELECT a.id, a.name, b.city FROM $table_1 AS a NATURAL JOIN $table_2 AS b");
$sth->execute;
$sth->dump_results;
$dbh->disconnect;
与文件名,extention输出这是一个错误?
猫test_1.csv
id,name
1,Brown
2,Smith
5,Green
猫test_2.csv
id,city
1,Laramie
2,Watertown
8,Springville
你也可以提供csv文件中的示例数据。 – Space 2010-05-07 07:52:09