我有一个Excel文件,其中有一些西班牙字符(波浪号等),我需要将其转换为CSV文件作为导入文件使用。然而,当我将另存为CSV时,它会破坏不是ASCII字符的“特殊”西班牙字符。它似乎也这样做的左右引号和长破折号,似乎是来自最初的用户在Mac中创建Excel文件。

由于CSV只是一个文本文件,我确信它可以处理UTF8编码,所以我猜这是Excel的限制,但我正在寻找一种方法,从Excel到CSV,并保持非ascii字符完整。


当前回答

用记事本+

这将修复Excel保存的损坏的CSV文件,并以适当的编码重新保存它。

从Excel导出CSV 加载到notepad++ 解决编码 保存

Excel保存在CP-1252 / Windows-1252中。在notepad++中打开CSV文件。选择

Encoding > Character Sets > Western European > Windows-1252

Then

Encoding > Convert to UTF-8
File > Save

首先告诉notepad++编码,然后转换。有些其他答案在转换时没有先设置正确的编码,这会使文件更加混乱。他们会把原本应该是“達”的东西变成“達”。如果您的字符不符合CP-1252,那么它在保存为CSV时就已经丢失了。用另一个答案。

其他回答

我发现OpenOffice的电子表格应用程序Calc非常擅长处理CSV数据。

在“另存为…”对话框中,单击“格式选项”可获得CSV的不同编码。LibreOffice的工作原理与AFAIK相同。

对于那些有崇高的文本:保存编码utf-16 LE与BOM应该这样做;-)

另一个我觉得有用的例子是: “数字”允许在保存为CSV时进行编码设置。

另一种方法是在记事本中打开UTF-8 CSV文件,它将正确显示。 然后将所有的“,”替换为制表符。 将所有这些粘贴到一个新的excel文件中。

Easy way to do it: download open office (here), load the spreadsheet and open the excel file (.xls or .xlsx). Then just save it as a text CSV file and a window opens asking to keep the current format or to save as a .ODF format. select "keep the current format" and in the new window select the option that works better for you, according with the language that your file is been written on. For Spanish language select Western Europe (Windows-1252/ WinLatin 1) and the file works just fine. If you select Unicode (UTF-8), it is not going to work with the spanish characters.