LOAD DATA INFILE - Importing Data from an Excel Spreadsheet
I have an Excel Spreadsheet with 25,000+ records to be imported into a database table.
I already re-sorted the columns to match my database fields, however when I tried exporting as a CSV to import via PHPMyAdmin, I got a puzzling error, "Invalid field count in CSV input on line 1."
Puzzling because I had the correct number of columns! So I'm chalking that up to some hidden Excel formatting.
So some googling later I found myself here, and learnt about "LOAD DATA INFILE".
How exactly do I use that function?
I saved and uploaded the data as a tab-delimited txt file, then ran a file called "load-data.php" with the following;
// Connect to Database
@ include($_SERVER['DOCUMENT_ROOT'] .'/Hidden/DatabaseInfo.php');
@ mysql_select_db($db_Database) or die("Error.");
// Load Data from Text File
LOAD DATA INFILE '/home/username/public_html/Database.txt';
// Dis-connect from Database
This gave me a syntax error though;
What am I doing wrong?
Parse error: syntax error, unexpected T_STRING in /home/username/public_html/load-data.php on line 8