Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by DrAxeman (Beadle)
on Aug 10, 2005 at 00:38 UTC ( #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?


Comment on Re^2: Process and combine two CSV files into one
Select or Download Code
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
Node Status?
node history
Node Type: note [id://482473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-12-18 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (43 votes), past polls