So I'm trying to create a MySQL table from a CSV file using this script: https://github.com/uzi88/PHP_MySQL_wrapper#create-table-from-csv-file
The script I'm using is a slight modification to the one in the link. The only difference is that the script I'm using is made to loop through a list. Here's the modified part:
$filename = 'csv_list.txt';
$contents = file($filename);
/* Loops through list of CSV-files and create a table for each CSV-file */
foreach($contents as $line) {
/* Cuts off file extension */
$file_info = pathinfo($line);
$file_name = $file_info['filename'];
$db->dropTable($file_name);
$db->createTableFromCSV('/csv/'.$file_name.'.csv', $file_name);
}
But I get the error "ERROR -> NO -> 0 - DESC -> - CALL -> Function createTableFromCSV in csv_to_mysql.php on line 32"
.
I can't seem to find any information about this error.
Here are a few rows from the CSV file I'm trying to import.
Disease,County,Year,Sex,Count,Population,Rate,CI.lower,CI.upper,Unstable
Amebiasis,California,2001,Total,571,34514777,1.654,1.521,1.796,
Amebiasis,California,2001,Female,176,17340743,1.015,0.871,1.176,
Amebiasis,California,2001,Male,365,17174034,2.125,1.913,2.355,
Amebiasis,El Dorado,2006,Total,0,175258,0,0,2.105,-
Amebiasis,El Dorado,2006,Female,0,87654,0,0,4.208,-
Amebiasis,El Dorado,2006,Male,0,87604,0,0,4.211,-
Amebiasis,El Dorado,2007,Total,1,177195,0.564,0.014,3.144,*
Amebiasis,El Dorado,2007,Female,1,88622,1.128,0.029,6.287,*
I've also tried with a new file where I removed the column "Unstable" because some values where empty. I also renamed CI.lower and CI.upper
Disease,County,Year,Sex,Count,Population,Rate,CIlower,CIupper
Amebiasis,California,2001,Total,571,34514777,1.654,1.521,1.796
Amebiasis,California,2001,Female,176,17340743,1.015,0.871,1.176
Amebiasis,California,2001,Male,365,17174034,2.125,1.913,2.355
Here's a link to the complete CSV file: https://cdph.data.ca.gov/api/views/yijp-bauh/rows.csv?accessType=DOWNLOAD