MySQL Error: "Invalid field count in CSV input on line 2"

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

  1. #1
    I'm new to MySQL and trying (for hours) to import a csv file.
    The phpMyAdmin-import settings are as follows:
    -csv
    -fields terminated by ;
    fileds enclosed by "
    fields escaped by \
    lines terminated by auto
    column names [left empty]

    The first line loads fine, the 2nd and 3rd do not,
    I have tried putting the first and second into the first position, but it still gets and error for that line:

    Line 1 (works):
    1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

    Line 2 (not working, error)
    1,xxxxxxx2,xxxxxxxx3,xxxxxxxxxxxxxxxxxxx4,5,xxxxx6,xx7,xxxx8,xxxxxxxxxx9,xxxxxxxxxxxxx10,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx11,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx12,xxxxxxx13,14,x15,x16,x17,x18,xxx19,20

    Line 3 (not working, error, this was the original error)
    1,Biodiesel,somestore,35 Highway 75 South,_,Townn,AL,33376,205-444-444,Public - see hours,6:30am-9pm M-F 7am-8pm Sat 10am-6pm Sun,Cash AmericanExpress Discover MasterCard VISA Voyager WrightExpress,6/30/2007,_ ,_ ,_ ,_ ,_ ,bg_lat,bg_long


    I did a nearly identical project yesterday, and it worked fine.

    Edit:

    I just got an identical file to work, except it is tab delimited instead of commas. Although no longer 'urgent', the above question is still a very curious thing that i would like to know. Line 1 worked in that first test, but line 2 did not.
     
    RogerDodgr, Jul 25, 2007 IP
  2. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #2
    what field types do you have in that table? int/varchar/text?
     
    gibex, Jul 25, 2007 IP
  3. RogerDodgr

    RogerDodgr Well-Known Member

    Messages:
    267
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #3
    gibex, I'm using varchar except for the first column which is the key; for the key I'm using integer.
     
    RogerDodgr, Jul 25, 2007 IP
  4. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Have you tried importing through the command line at all?
     
    rgchris, Jul 26, 2007 IP
  5. smftre

    smftre Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I actually had this problems a few months ago and wrote about what solved it for me here: andrewodendaal.com/phpmyadmin-invalid-field-count-in-csv-input-on-line-1/
     
    smftre, Aug 12, 2010 IP
  6. wwwseo

    wwwseo Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    use MySQL GUI tool for import data.
     
    wwwseo, Aug 12, 2010 IP
  7. Josef Miran

    Josef Miran Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    +1
    import data into mysql via the GUI is very simple, open the Import Wizard and specify the file import and other parameters. To import the data I use dbForge.
    the lack of GUI that there is no import data via the command line.
     
    Josef Miran, Aug 13, 2010 IP
  8. gordi555

    gordi555 Active Member

    Messages:
    537
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #8
    Thanks for that smftre, worked for me!
     
    gordi555, Jan 26, 2011 IP