简体   繁体   English

无法使用phpmyadmin向导将csv导入mysql数据库

[英]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. 我正在尝试使用phpmyadmin将csv文件导入到我的mysql数据库中,但始终出现错误。

Here is how the csv looks: 这是csv的外观:

在此处输入图片说明

Then I import like this: 然后我像这样导入: 在此处输入图片说明

And get the error: "Invalid parameter for CSV import: Fields enclosed by". 并得到错误:“ CSV导入参数无效:字段由”。 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. 由于前导逗号,日期映射为“描述”,这基本上为itemId提供了一个空值(或null,具体取决于如何处理导入),这似乎不是您想要的。 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. 我必须删除csv的第一行(包含列名),从而解决了该问题。 Everything got imported properly. 一切都正确导入。

Note, the date field needed reformatting to match SQL's date format yyyy-mm-dd. 注意,日期字段需要重新格式化以匹配SQL的日期格式yyyy-mm-dd。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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