in reply to Load CSV file into Database

Text::CSV or Text::CSV_XS is the way to go, but it can be done more conventionally, just in case the module is not available or you want to roll your own.

.......connect to database....... .........upload CSV file .......... my $stmt ="DELETE FROM list" ; my $sth = $dbh->prepare($stmt); $sth->execute(); $stmt =qq/LOAD DATA LOCAL INFILE "..\/$csvtoupload" INTO TABLE list FI +ELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY """" LINES TERMINATED B +Y "\r" IGNORE 1 LINES/; $sth = $dbh->prepare($stmt); $sth->execute(); unlink "../$csvtoupload" or die "Error deleting uploaded file: $!\n"; ...close db.....

Of course, a bit more needs to be known about the original CSV, like does the first row need to be ignored.


—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot