Import .xls file into a mysql database

Import .xls file into a mysql database

I have a .xls file that i would like to import into a mysql database, I am ok creating the mysql table _temp in my webspace and try this code in mysql:


LOAD DATA INFILE
'D:/11_02_11.xls'
INTO TABLE _temp
FIELDS TERMINATED BY ',' IGNORE 1 LINES;

But error:

[Err] 1261 - Row 1 doesn’t contain data for all columns

Any ideas most welcome.

Regards.

Your temp table contains more columns than row 1 of the xls file.

Thanks Guido… you are right… :wink:


LOAD DATA INFILE 'D:/11_02_11.xls' 
REPLACE INTO TABLE _temp 
FIELDS TERMINATED BY ',' 
OPTIONALLY ENCLOSED BY '\\"' 
LINES TERMINATED BY '\\r\
' IGNORE 1 LINES ;

The fields are in the same order in the DB as they are in the .xls

http://dev.mysql.com/doc/refman/5.1/en/load-data.html