I tried something similar to this, but got unexpexcted results. (My skills with SQL is even worse than my skills with Perl.)

# Connect to the database, (the directory containing our csv file(s)) my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;"); # Associate our csv disk file with the table name 'results' $dbh->{'csv_tables'}->{'info'} = { 'file' => "psinfooutputfile.csv"}; $dbh->{'csv_tables'}->{'hosts'} = { 'file' => "netbiosoutputfile.csv"} +; ###### my @row = $dbh->selectall_arrayref("SELECT * FROM hosts, info WHERE ho +sts.IP = info.IP"); print Dumper @row;

Produced

$VAR1 = [ [ '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10', '10.160.0.10' ],

I am assuming that there is an issue with my SQL.

I figured it out. I need to name each Column in my statement, not just an *.

My problem is that it isn't joining data from one of the tables.
# Connect to the database, (the directory containing our csv file(s)) my $dbh = DBI->connect("DBI:CSV:f_dir=.;csv_eol=\n;"); # Associate our csv disk file with the table name 'results' $dbh->{'csv_tables'}->{'info'} = { 'file' => "psinfooutputfile.csv"}; $dbh->{'csv_tables'}->{'hosts'} = { 'file' => "netbiosoutputfile.csv"} +; ###### my @row = $dbh->selectall_arrayref("SELECT IP, Domain, ServerName, Day +sUptime, OS, RAM, OSSP, InstallDate, CPUSpeed, CPUCount, CPUType FROM + hosts, info WHERE hosts.IP = info.IP"); print Dumper @row;

Output;
$VAR1 = [ [ '10.160.0.10', '0', '', '19', 'Microsoft_Windows_2000_Server_Domain_Controller', '1024', '4', '12_2_2003', '995', '1', 'Intel_Pentium_III' ], ]

UPDATE:
I modified the top line of the file who's data wasn't getting joined and found that the data included there was the ONLY data being used. I changed it to an INNER JOIN and it looks like it's working.


In reply to Re^2: Process and combine two CSV files into one by DrAxeman
in thread Process and combine two CSV files into one by DrAxeman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.