简体   繁体   English

在 Excel 2016 中打开 CSV 文件

[英]Opening CSV files in Excel 2016

I have a new install of Excel 2016, that hates CSV files.我有一个新安装的 Excel 2016,它讨厌 CSV 文件。 It opens them with everything in one column flagpole style, down column A, with commas and speech marks visible.它以一列旗杆样式打开它们,在 A 列下方,逗号和语音标记可见。

Salient points:要点:

  1. I have two machines, desktop and laptop, both running same version of Excel.我有两台机器,台式机和笔记本电脑,都运行相同版本的 Excel。 Desktop works fine, opens the same problem files formatted correctly.桌面工作正常,打开格式正确的相同问题文件。

  2. I can create CSV files on laptop, save those, open them again on laptop, and it's fine.我可以在笔记本电脑上创建 CSV 文件,保存它们,在笔记本电脑上再次打开它们,这很好。

  3. Even opening it in Notepad++, saving in the hope of some sort of file format normalisation, and still no good.即使在 Notepad++ 中打开它,希望能进行某种文件格式规范化,但仍然没有好处。

  4. I have compared regional settings and almost all settings in Excel.我比较了区域设置和 Excel 中的几乎所有设置。

  5. I tried renaming the file to TXT, it brought up the text file conversion dialogue, I chose comma delimited.我尝试将文件重命名为 TXT,它打开了文本文件转换对话框,我选择了逗号分隔。 First time it ignored that, still got everything in column A, second attempt, that actually worked, however, that is a pants solution, I want to be able to just natively open CSV files without saving as TXT, I use many different ones every day.第一次它忽略了这一点,仍然在 A 列中获得了所有内容,第二次尝试,实际上有效,但是,这是一个裤子解决方案,我希望能够在不保存为 TXT 的情况下直接打开 CSV 文件,我每次都使用许多不同的文件日。

Anyone got any ideas?有人有任何想法吗?

Thanks in advance.提前致谢。

CSV files are character separated value files, not necessarily comma separated. CSV 文件是字符分隔值文件,不一定是逗号分隔。 For more than half the world the separator character is a semicolon (;), not a comma (,)对于超过一半的世界,分隔符是分号 (;),而不是逗号 (,)

Excel 2016 properly respects your Windows regional settings, and uses the specified List Separator character Excel 2016 正确尊重您的 Windows 区域设置,并使用指定的列表分隔

One solution is to change your regional settings for the List Separator attribute to the character you want Excel to default to using, eg a comma (,)一种解决方案是将列表分隔符属性的区域设置更改为您希望 Excel 默认使用的字符,例如逗号 (,)

This can be changed in the operating system Control Panel , under Region settings, Additional Settings, List separator这可以在操作系统控制面板中的区域设置、附加设置、列表分隔符下进行更改

For various reasons some people seem to have the incorrect regional settings for the culture they most commonly work in, and therefore have semicolon as the default separator由于各种原因,有些人似乎对他们最常工作的文化有不正确的区域设置,因此将分号作为默认分隔符

If you prefer not to change your operating system regional setting to what you think is normal for CSV files, you can change the default behavior in Excel with the Use system separators checkbox under the File/Options/Advanced menu如果您不想将操作系统区域设置更改为您认为对 CSV 文件来说是正常的,您可以使用文件/选项/高级菜单下的使用系统分隔符复选框更改 Excel 中的默认行为

If you want custom options each time you open a CSV file, use the Data/From Text menu, but this becomes slow and awkward for lots of files如果每次打开 CSV 文件时都需要自定义选项,请使用“数据/来自文本”菜单,但这对于许多文件来说变得缓慢且笨拙

CSV References: CSV 参考资料:

I've found a way of saving messy CSV files into a nice table format but I'm not sure if it will work for your case.我找到了一种将凌乱的 CSV 文件保存为漂亮表格格式的方法,但我不确定它是否适用于您的情况。

Data -> New Query -> From File -> From CSV数据 -> 新查询 -> 从文件 -> 从 CSV

By opening the CSV file this way, a pop-up 'Query Editor' window will appear with a nicely organised table format where you can edit, save and load into your excel sheet.通过以这种方式打开 CSV 文件,将出现一个弹出的“查询编辑器”窗口,其中包含一个组织良好的表格格式,您可以在其中编辑、保存和加载到您的 Excel 工作表中。

I hope this helps.我希望这有帮助。

For me the solution was to:对我来说,解决方案是:

Data > From Text > Choose your csv file数据 > 从文本 > 选择您的 csv 文件

Then you can define all the import settings for csv files.然后您可以定义 csv 文件的所有导入设置。

I found another way to fix this, without changing your windows local settings.我找到了另一种解决此问题的方法,而无需更改 Windows 本地设置。 In Excel, you go to File > Options > Advanced.在 Excel 中,转到文件 > 选项 > 高级。 Un-check the "Use System Separators" within the Editing Options and change the Decimal separator with "," and the Thousands Separator ".".取消选中编辑选项中的“使用系统分隔符”,并将小数分隔符更改为“,”和千位分隔符“.”。

Even it does look more like a bug than a feature of Excel 2016, it works without changing the Windows Local settings, and it's just a local Excel change.即使它看起来更像是一个错误而不是 Excel 2016 的功能,它也可以在不更改 Windows 本地设置的情况下工作,并且它只是本地 Excel 更改。

Just had this same problem.刚刚有同样的问题。 Changing the file extension from csv to txt and opening in Excel brings up the classic wizard so you can map the strings to fields.将文件扩展名从 csv 更改为 txt 并在 Excel 中打开会显示经典向导,以便您可以将字符串映射到字段。

I have quite a complex csv file where none of the suggestions worked out for me.我有一个相当复杂的 csv 文件,其中没有任何建议适合我。 So I ended up using LibreOffice Calc for the job.所以我最终使用 LibreOffice Calc 来完成这项工作。 It worked like a dream.它像梦一样工作。

The correct answer is to edit your regional settings as suggested above (if a long term change in behavior is desired)正确的答案是按照上面的建议编辑您的区域设置(如果需要长期改变行为)

Control Panel -> Region -> Additional Settings -> List separator : Control Panel -> Region -> Additional Settings -> List separator

But for my purposes a simple Edit -> Find and Replace using Notepad to replace all commas with semi-colons was a quick and dirty solution that I preferred.但就我而言,简单的Edit -> Find and Replace使用Notepad将所有逗号替换为分号是我更喜欢的快速而肮脏的解决方案。

Despite the comment that csv means 'Character Separated Values', in Office 2016 my .csv file association to Excel still says 'Microsoft Excel Comma Separated Values File'.尽管评论 csv 表示“字符分隔值”,但在 Office 2016 中,我的 .csv 文件与 Excel 的关联仍然显示“Microsoft Excel 逗号分隔值文件”。

I had the same issue on Mac OS X El Captain.我在 Mac OS X El Captain 上遇到了同样的问题。 The answer givenhere worked for me. 这里给出的答案对我有用。 Reproducing it here in case the link doesnt work in future:在这里复制它以防链接将来不起作用:

  1. Close the Excel application关闭 Excel 应用程序
  2. Click on the Apple button点击苹果按钮
  3. Select System Preferences选择系统偏好设置
  4. Select Language and Region选择语言和地区
  5. Click Advanced单击高级
  6. Change the Decimal separator from a comma (,) to a full stop (.)将小数分隔符从逗号 (,) 更改为句号 (.)
  7. Then click on Ok/Save然后点击确定/保存
  8. Test the Excel import again再次测试 Excel 导入

When changing the list separator, make sure it doesn't overlap with the decimal symbol and the digit grouping characters.更改列表分隔符时,请确保它不与十进制符号和数字分组字符重叠。 I had to change my list separator to (,) my decimal to (.) end my digit grouping to (').我不得不将我的列表分隔符更改为 (,) 我的小数点为 (.) 将我的数字分组结束为 (')。 Now .CSV opens lekker!!!现在.CSV打开lekker!!!

I had the same problem, I fixed it in this way (Excel 2020)我遇到了同样的问题,我以这种方式修复了它(Excel 2020)

Data -> Text to Columns数据 -> 文本到列

Now you can configure as you wish the CSV delimiters/endlines...现在您可以根据需要配置 CSV 分隔符/结束符...

文本到列

在我的excel中,它是:数据>获取数据>从文件>从文本/csv

Try opening in excel, then using text to columns, based on commas.尝试在 excel 中打开,然后基于逗号使用文本到列。 You could probably create some simple vba to open it in that way too.您也可以创建一些简单的 vba 来以这种方式打开它。

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

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