Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Process and combine two CSV files into one

by DrAxeman (Scribe)
on Aug 10, 2005 at 00:38 UTC ( [id://482473]=note: print w/replies, xml ) Need Help??


in reply to Re: Process and combine two CSV files into one
in thread Process and combine two CSV files into one

I tried it and got a error:
SQL ERROR: Can't find column definitions!

So I tried adding column headings as shown in the DBD:CSV page. Same error. Google doesn't produce anything for that error either.
# Associate our csv disk file with the table name 'results' $dbh->{'csv_tables'}->{'info'} = { 'file' => "psinfooutputfile.csv"}; $dbh->{'csv_tables'}->{'disks'} = { 'file' => "disk_results.csv"}; $dbh->{'csv_tables'}->{'hosts'} = { 'file' => "netbiosoutputfile.csv"} +; $dbh->{'csv_tables'}->{'hosts'} = { 'file' => "template.csv"}; ###### $dbh->do("DROP TABLE IF EXISTS template"); $dbh->do("CREATE TABLE template (IP CHAR(64), ServerName CHAR(64), Dom +ain CHAR(64), DaysUptime CHAR(64), OS CHAR(64), RAM CHAR(64), OSSP CH +AR(64), InstallDate CHAR(64), CPUSpeed CHAR(64), CPUCount CHAR(64), C +PUType CHAR(64)) AS SELECT IP, ServerName, Domain, DaysUptime, OS, RAM, OSSP, I +nstallDate , CPUSpeed, CPUCount, CPUType FROM hosts LEFT JOIN info ON hosts.IP = info.IP ");

Please note, the CHAR (64) was just a dummy value used for testing ONLY.
Do I have a syntax error?

Replies are listed 'Best First'.
Re^3: Process and combine two CSV files into one
by jZed (Prior) on Aug 10, 2005 at 00:45 UTC
    That's not the syntax supported by SQL::Statement (see SQL::Statement::Syntax). The columns for creating the table are specified in the SELECT part and created in the new table automatically. So change the create statement to:
    $dbh->do(" CREATE TABLE template AS SELECT IP, ServerName, Domain, DaysUptime, OS, RAM, OSSP, InstallDate, CPUSpeed, CPUCount, CPUType FROM hosts LEFT JOIN info ON hosts.IP = info.IP ");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://482473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-03-28 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found