mysql 表导入向导无法导入 csv 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34369465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:29:52  来源:igfitidea点击:

mysql table import wizard fails to import a csv file

mysqlcsvencodingimport

提问by user1907514

I am trying to import a csv file (Window 10), created by notepad++, using semicolons as delimiters, extension .csv.

我正在尝试导入由 notepad++ 创建的 csv 文件(Window 10),使用分号作为分隔符,扩展名为 .csv。

I use Mysql Workbench 6.3, import wizard. Encode in notepad++ is UTF-8, and the mysql table I am trying to load is utf-8 default collation

我使用的是 Mysql Workbench 6.3,导入向导。notepad++ 中的编码是 UTF-8,我尝试加载的 mysql 表是 utf-8 默认排序规则

Import wizard fails to import and shows two messages: Table data Import: Can't analyze the file, please try to change encoding type. If that doesn't help, maybe the file is no: csv, or the file is empty

导入向导无法导入并显示两条消息:表数据导入:无法分析文件,请尝试更改编码类型。如果这没有帮助,也许文件不是:csv,或者文件是空的

Unhandled exception: 'ascii' codec can't encode character u'\xfa' in position 1: ordinal not in range (128)

未处理的异常:“ascii”编解码器无法在位置 1 中对字符 u'\xfa' 进行编码:序号不在范围内 (128)

How can I do to trace this error. I tried several encodings for the file, but the error persists.

我该怎么做才能追踪这个错误。我为文件尝试了几种编码,但错误仍然存​​在。

thanks

谢谢

回答by Dinesh Ravi

There are 3 csv

有3个csv

While you are saving the excel data using "Save as" option select msdos .csv format. Note that there are 3 csv format out of it select only MS-DOS .csvas highlighted in image.

当您使用“另存为”选项保存 excel 数据时,选择 msdos .csv 格式。请注意,其中有 3 种 csv 格式,仅选择图像中突出显示的MS-DOS .csv

回答by Bi?t Tu?t

Using import Button tool in the SQL result. See the image

在 SQL 结果中使用导入按钮工具。看图

S? d?ng c?ng c? import trên c?a s? cau l?nh SQL.

?  d?ng c?ng c?  进口trên c?as?  cau l?nh SQL。

回答by SunnySonic

In case somebody finds this like me and needs a solution:

如果有人像我一样发现这个并需要解决方案:

https://help.surveygizmo.com/help/encode-an-excel-file-to-utf-8-or-utf-16

https://help.surveygizmo.com/help/encode-an-excel-file-to-utf-8-or-utf-16

This explains how to save the file with the correct encoding.

这解释了如何使用正确的编码保存文件。

回答by Pt. Raman Sharma

Try libreoffice calc or ms-office excel for creating the csv files no matter what delimeter is used. Make sure to set your encoding to UTF-8. IT will work for you.

无论使用什么分隔符,都可以尝试使用 libreoffice calc 或 ms-office excel 来创建 csv 文件。确保将编码设置为 UTF-8。它会为你工作。