in reply to Re: Best way to match a hash with large CSV file
in thread Best way to match a hash with large CSV file
So you are saying is to do the load of the CSV to the DB and the prepare once, and just execute the queries for each value in the hash? using placeholders? Like:
$sth = $dbh->prepare( " SELECT * FROM csvtable WHERE SITE LIKE ? AND H +OUR = ? " ); foreach my $key (keys %cell_peakhr) { $sth->execute( $key, $cell_peakhr{$key}); @db_result = $sth->fetchrow_array() if (scalar(@db_result) < 1) { $db_result[0] = $date; $db_result[1] = $cell_peakhr{$key}; $db_result[2] = $key; foreach my $count (3..$row_size-1) { $db_result[$count] = "-"; }#foreach }#if print OUT join(',',@db_result)."\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Best way to match a hash with large CSV file
by chromatic (Archbishop) on Nov 03, 2011 at 21:22 UTC |