Written by Yeni Setiawan18/07/2009
Invalid field count in csv input on line 1
Technical Stuffs Article
When importing CSV data into my MySQL database using PHPMyAdmin, I found following error: Invalid field count in csv input on line 1.
It’s odd since I’ve manually count field numbers and compared with column on my CSV files, they’re exactly match.
Then I found something strange. PHPMyAdmin is automatically use semicolon ( ; ) as field delimiter instead of comma ( , ). Quick fix for this problem is to change the delimiter symbol manually.
In the picture above, I replaced semicolon (rounded with blue circle) with comma and everything is alright.
You may also like
38 comments
Leave a ReplyCancel reply
Archives
- April 2025
- March 2025
- February 2025
- November 2023
- January 2023
- October 2022
- August 2022
- April 2022
- March 2022
- January 2022
- July 2021
- October 2020
- August 2020
- June 2020
- January 2020
- November 2019
- July 2019
- December 2018
- October 2018
- September 2018
- August 2018
- May 2018
- March 2018
- February 2018
- December 2017
- September 2017
- June 2017
- March 2017
- February 2017
- January 2017
- December 2016
- November 2016
- October 2016
- August 2016
- July 2016
- June 2016
- May 2016
- April 2016
- March 2016
- February 2016
- January 2016
- December 2015
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- May 2014
- April 2014
- March 2014
- February 2014
- November 2013
- October 2013
- September 2013
- July 2013
- June 2013
- January 2013
- December 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- June 2006
- March 2006
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | |||||

it’s not a bug, it follow old excel csv pattern
Thanks! This really helped alot. Spent a good while trying to find problem, and its something as small as this.
Thanks again
ndal….kowe kie mbahas opo tho?
@mh
Thanks for your acknowledgement 😉
@jport
nice to hear that 🙂
WOW thanks for the info, i uploaded a csv files successfully because of your advise. Great job!
sopo yo.admine..salam kenal..
sopo = siapa
admine = administratornya
ember jeng
you’ve got no idea how much you just helped me out right here!
Thanks a million!
hehehe, biasanya itu dari mysql lama ke mysql baru.
Nice post, it is working fine.
Thank you, thank you, thank you!
I’d been pulling out my hair for two hours until I stumbled upon your site.
Comma vs. semicolon… phew – I didn’t spot that. Amazing what grief one pixel’s difference can cause.
phpMyAdmin can go stuff its semicolon right up its last two syllables of the aforementioned punctuation mark.
Terima kasih banyak
Thank you. I have been looking all day on the web trying to get an answer. My upload worked fine.
Cheers,
Alan
thank you so much ,helped me a lot . .
Thanks, This had been driving me mad for some time!
Wow to think PHP used to not do this and does now.
This is stupid and the sheer number of posts i have seen of users with this problem i can’t believe they did soemthing so stupid just to maintain the old excel standard, clearly CSV stands for COMMA separated value.
this just saved me a whole bunch of time
thanks, it saved my time.
Sunny.
SESAT LOhh
In my CSV file the fields were surrounded by ” (double quotes).
Please be sure there are no double quotes INSIDE THE FIELDS. Open your CSV file in Excel or scalc (openoffice suite):
– In scalc go to Edit > Find /Replace
– In Excel follow this steps: http://support.microsoft.com/kb/288291
Replace all the ” (double quotes) with ‘ (single quotes).
Another problem was with the DATETIME fields in MYSQL. In scalc select them all and right-click on them > Format Cells > and put “JJ-MM-DD UU:MM:SS” in the Format code box.
I’m only allowed to have in MYSQL first the year, then the month and then the day. For example “2009-12-29”.
After following these steps it worked for me.
And BTW, if there are still problems, open your CSV with Notepad or another text editor and check if every line has the right count of fields.
Thanks a lot, saved a lot of time
Wow, thanks for this… I was going insane 🙂 x
Thank you very much, sooo simple!
Hi,
its relay Great!
its helped me alot.
really Thanks….
Thanks….
Thanks….
Thanks….
Thanks….
Thanks….
vivek
CHPL pune
i have same problem but still unable to solve it as per your above instructions
I have funded best solution
First of all open CSV file in Microsoft Excel and save it again with new name then
To solve this I had to do the following:
Import
Browse for your csv file.
Select CSV using LOAD DATA (rather than just CSV)
Change “Fields terminated by” from “;” to “,”
Make sure “Use LOCAL keyword” is selected.
Click “Go”
Cheers for this, really saved my ass
The above problem is probably due to the Windows default setting in Regional Settings (Control Panel) for the CSV file separator. It seems the USA and UK use different default values.
Excellent tip, you solved my problem instantly with CSV imports!
Another useful trick, when you’re having problems importing an Access table, is to open up the file in TextPad (or some other editor) and examine your data. You’ll probably find many errors. For instance if you have ” in your text field you’ll have to change it something else. I find that Access search and replace can be a little tempermental, so simply telling Access to replace the ” with a ^ doesn’t always work as expected.
Cool Stuff!!!
Great job, I got this when trying to upload a csv database after editing it, I thought I broke it lol.
Thanks!
Floris: Thanks!
I’ve tried everything you said but only the first row out of 142 rows gets inserted. I also have this issue. I have 8 columns A thru H.
In the DB the first field is Product_ID and its set to auto increment. Even only after only one row being inserted the data in the CSV file does not transfer over to the same DB fields as they should (out of sync). Very frustrated.
Thank’s a lot for decision of the problem. It’s work!
Thanks a billion!
Thanks! I also had trouble with uploading a CSV created in Excel, but removing quotation mark in ‘Fields enclosed by’ field I was able to fix it.
Thanks again!
VERY helpful thanks. I kept getting errors! This worked perfectly.
Thanks again,
Mike
oh .. thank you so much ^^” .. i try to solve this problem by myself very long time