How to get data from Excel to MySql?

Discussion in 'MySQL' started by RogerDodgr, Jul 20, 2007.

  1. #1
    I'm a total newb to MySQL but I'm trying. I like statistics and government data that comes in Excel spread sheets. This is how I just currently got Excel it into MySQL. I know there has to be an easier way (right????):

    Step 1: Copy entire column from source Excel sheet
    step 2: Paste to excel spreadsheet that looks like this (columns 'B' and 'D' in this example) :
    column a:
    INSERT INTO `table` VALUES ( '
    column b:
    some data
    column c:
    ','
    column d:
    more data
    column e:
    ');

    Step 3:
    copy entire new excel sheet and paste to MS Notepad.

    Step 4: Save and upload.

    Is there an quicker/easier way?
     
    RogerDodgr, Jul 20, 2007 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    That is a pretty resourceful way that you are doing it.

    You can buy a data parsing program. It will allow you to define the incoming fields and the outgoing fields (mysql). One can process a rather large file in minutes. The most difficult part is defining the fields.

    One name that I recall because they used to have a 30 free trial is "Parserat".
     
    Colbyt, Jul 21, 2007 IP
  3. RogerDodgr

    RogerDodgr Well-Known Member

    Messages:
    267
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #3
    Thank you Colbyt. I have worked out another way in the mean time. But, If I have more problems I will definetly look into Parserat.

    In case anyone reads this, the simple solution should have been
    1) save the Excel file as a .csv file.
    2) upload through phpMyAdmin. I had to change the "fields terminated by" field from (; ) to (,).

    However, this would not work for me, i kept getting the error, "Invalid field count in CSV input on line 1"

    What worked for me was copying the excel fields into Googles online spreadsheets and then exporting as csv file. Google's free csv file worked; Microsoft did not!

    ---
    digresion---> spreadsheets, i have found, can be very good at creating 100's of lines of code.
     
    RogerDodgr, Jul 21, 2007 IP