简体   繁体   中英

Cannot import csv into mysql database using phpmyadmin wizard

I am trying to import a csv file into my mysql database using phpmyadmin but keep getting errors.

Here is how the csv looks:

在此处输入图片说明

Then I import like this: 在此处输入图片说明

And get the error: "Invalid parameter for CSV import: Fields enclosed by". I have tried to put the columns in quotes " or put a semicolon after each column, but keep getting errors.

Yeah, you have an extra field in there. For instance, with your example line of:

itemId,date,description,amount
,1,2/13/2013,Fabrics,44

the date maps to "description" because of the leading comma, which basically gives an empty (or null, depending on how the import is handled) value to itemId, which doesn't seem to be what you want. Where'd that extra comma come from -- was this an export from some program?

Also, in this case you don't have anything enclosing the fields so you should just be able to leave that value empty, which seems to have worked for you once you got the column count corrected.

I had to remove the first line of the csv (containing the column names) and that solved the issue. Everything got imported properly.

Note, the date field needed reformatting to match SQL's date format yyyy-mm-dd.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM