load data local infile 'uniq.csv' into table tblUniq(field1, field2, field3)
fields terminated by ','
enclosed by '"'
lines terminated by '\n'
Ini adalah solusi opsional, satu-satunya yang Anda perlukan adalah skrip PHP\Perl\Python untuk membuat ulang semua file, dan menyisipkannya satu per satu
Kode PHP:
<?php
$basedir = "/path/to/dir"
if ($handle = opendir($basedir)) {
while(false !== ($entry = readdir($handle))) {
$query = "LOAD DATA LOCAL INFILE $basedir$entry
INTO TABLE tableName
FIELDS
TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
IGNORE 1 LINES");
if(DEBUG) { echo $query . "\n"; }
if(!mysql_query($query)) {
die('MySQL error: ' . mysql_error());
}
}
} else {
echo "Could not open $basedir";
}
?>