SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    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:

    Code:
    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.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,509
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Your temp table contains more columns than row 1 of the xls file.

  3. #3
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    Your temp table contains more columns than row 1 of the xls file.
    Thanks Guido... you are right...

    Code:
    LOAD DATA INFILE 'D:/11_02_11.xls' 
    REPLACE INTO TABLE _temp 
    FIELDS TERMINATED BY ',' 
    OPTIONALLY ENCLOSED BY '\"' 
    LINES TERMINATED BY '\r\n' 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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •