如何在 Google 文档电子表格中用双引号将每个单元格括起来
我有 utf-8
数据,我想将其保存为 CSV。 我的旧版本 Excel 损坏了 utf-8
,因此我不得不使用能够完美处理 utf-8
的 google 电子表格。
我的一些数据中包含逗号,因此我必须用双引号将 thCSVsv 中的每个数据字段括起来。我有数百行,因此手动完成并且没有错误需要一些时间。
我怎样才能在谷歌文档电子表格中完成这个任务?
I have utf-8
data which I would like to save as CSV.
My old version of Excel mangles utf-8
, so I have to resort to using google's spreadsheet which handles utf-8
beautifully.
Some of my data have commas in them, so I must wrap every field of data in thCSVsv with double quotes. I have hundreds of lines, so it would take some time to do it manually and without error.
How can I accomplish this in google docs spreadsheet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
首先,为什么不将电子表格导出为 csv?谷歌已经内置了这个功能。它位于菜单“文件”>“下载为> CSV
但是,回答你的问题,将所有值用双引号括起来非常容易。假设所需的值位于 Sheet1 的 A 至 D 列上。在 Sheet2 的单元格 A1 上,只需放置以下公式:
双引号的问题在于它们被用作字符串分隔符,因此要将它们放在字符串内你必须连续输入两个。因此,一个“打开,两个”,一个“”,一个“关闭:)
First, why don't you just export your spreadsheet as csv? Google has that feature built-in. It's under the menu File > Download as > CSV
But, answering your question, it's pretty easy to wrap all values in doubles quotes. Let's say the desired values are on Sheet1 columns A to D. On Sheet2, cell A1, just place this formula:
The issue with the issue with the double quotes is that they're used as string delimiters, so to have them inside a string you have to type two consecutive. So, one " to open, two to have one "" and one " to close :)
您可以像这样使用
CHAR(34)
这将导致
You can use
CHAR(34)
like thisthis will result in
这是我的过程:
1)使用连接函数或使用上面的 Henrique 公式将每个单元格用双引号引起来。我通常使用连接,因为我通常有一两列我不想用双引号引起来。
2)导出CSV。您会注意到单元格被包裹起来,但带有三个双引号 (
"""
),而不是一个 ("
),因此...3) 在文本编辑器找到
"""
并替换为"
这应该会得到一个 CSV,其中单元格用双引号括起来。
This is my process:
1) wrap each cell in double quotes either using the concatenate function or by using Henrique's formula above. I generally use concatenate because I generally have a column or two that I don't want wrapped in double quotes.
2) export the CSV. You'll notice that the cells are wrapped but with three double quotes (
"""
) rather than one ("
) so...3) open the CSV in a text editor find
"""
and replace with"
That should get you a CSV with cells wrapped in double quotes.
您可以使用
=CHAR(34)
或任何需要双引号的地方。You can use
=CHAR(34)
or wherever you need double quotes.2021 年更新答案:
目前,下载 CSV 时,Google 表格会将所有包含逗号的单元格用引号括起来。一些挑剔的 CSV 读者可能不喜欢带引号的记录,而另一些则不喜欢不带引号的记录,但 Excel 可以很好地处理它。
将全部内容括在引号中的另一种方法是使用自定义格式。
格式-->数量-->更多格式 -->自定义数字格式
输入“@”
这会将所有字段括在引号中。
下载 CSV 并使用查找/替换将三引号 """ 减少为 "
Updated answer for 2021:
At this time, when downloading a CSV, Google Sheets wraps any cells containing commas with quotes. Some persnickety CSV readers may not like having records with quotes and others without, but Excel handles it fine.
Another way to do wrap all in quotes is by using a custom Format.
Format --> Number --> More Formats --> Custom number format
Enter "@"
This will wrap all fields in quotes.
Download the CSV and use find/replace to reduce the triple quotes """ to "
我通过添加 3 " 来实现这一点,然后谷歌表格删除了 2 个并显示了一个。
i've achieved this by adding 3 ", then google sheets deleted 2 and showed one.