ERROR - Error No: 1103 - Error: Incorrect table name 'Hospital_Value_Based_Purchasing__HVBP____Healthcare_Associated_Infection_Scores' - Call: Function createTableFromCSV in /home/dojob/public_html/drydo.com/csv_to_mysql/csv_to_mysql.php on line 46 ERROR - Error No: 0 - Error: - Call: Function createTableFromCSV in /home/dojob/public_html/drydo.com/csv_to_mysql/csv_to_mysql.php on line 46
require "MySQL_wrapper.class.php"; $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 ".csv"*/ $file_info = pathinfo($line); $file_name = $file_info['filename']; /*Replace "-" with "_" to be readable for server */ $file_name = preg_replace('/-/','_',$file_name);
$db->dropTable($file_name); $db->createTableFromCSV('../flashback_crawler/files/'.$file_name.'.csv', $file_name); }
/**Creates table from CSV file and imports CSV data to Table with possibility to update rows while import. * @param string $file - CSV File path * @param string $table - Table name * @param string $delimiter - COLUMNS TERMINATED BY (Default: ',') * @param string $enclosure - OPTIONALLY ENCLOSED BY (Default: '"') * @param string $escape - ESCAPED BY (Default: '\') * @param integer $ignore - Number of ignored rows (Default: 1) * @param array $update - If row fields needed to be updated eg date format or increment (SQL format only @FIELD is variable with content of that field in CSV row) $update = array('SOME_DATE' => 'STR_TO_DATE(@SOME_DATE, "%d/%m/%Y")', 'SOME_INCREMENT' => '@SOME_INCREMENT + 1') * @param string $getColumnsFrom - Get Columns Names from (file or generate) - this is important if there is update while inserting (Default: file) * @param string $newLine - New line delimiter (Default: auto detection use \n, \r\n ...) * @return number of inserted rows or false */
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)