绕过以 + 开头的字段的 excel csv 公式转换或者 -
我有一个 csv 文件,其内容为:
"x","y","-z"
当我导入它时,我得到:
如何绕过此转换?
更新
如果您尝试:
"x","y",="-z,a"
“,a”不会被导入。
如果你在前面加一个空格:
"x","y",=" -z"
或者
"x","y"," -z"
它会正常工作
I have a csv file with contents:
"x","y","-z"
When I import it I get:
How can I bypass this conversion?
Update
If you try:
"x","y",="-z,a"
The ",a" is not imported.
If you put a space in front:
"x","y",=" -z"
or
"x","y"," -z"
it will work fine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
在值前面加上等号
Prefix the values with equals signs
您的问题是,通过使用 CSV 扩展,您将强制 excel 使用其非常严格的 CSV 约定来解释文件,这通常会违背您想要执行的操作,除非 CSV 文件最初是由 Excel 创建的。导入此 CSV 文件的最简单、最可靠的方法是将其重命名为 TXT 文件,然后使用 Excel 中的导入功能以您想要的方式强制列。
Your problem is that by using the CSV extension, you are forcing excel to interpret the file using its very strict CSV conventions, and this will often go against whatever it is you're trying to do unless the CSV file was originally created by Excel. Your easiest, and most reliable method of importing this CSV file, is to rename it to a TXT file, and then use the import function in excel to coerce columns in exactly the way you want.
使用Excel有完全的区别>导入并双击 .CSV 文件。使用不同的解析器。
根据上面的评论,我发现在“+”或“-”符号之前前置空格适用于双击 .CSV 文件的情况。所以我的文件现在包含例如
There is a complete difference in using Excel > Import and double-click a .CSV file. Different parsers are used.
Based on the comments above, I figured out that prepending a space before a '+' or '-' sign works for the double-click .CSV file case. So my file now contains e.g.
我在 Excel 2003 中尝试了您的第一个示例,并且可以重现您的 #NAME 错误。
我的解决方案是打开文本文件并在导入向导(第 3 页)中将第三列指定为“文本”,同时选择正确的分隔符和文本限定符(第 2 页)。
无需对文本文件进行任何更改。
I tried your first example in Excel 2003 and could reproduce your #NAME eror.
My solution was to open the text file and to specify the 3rd column as "Text" in the import wizard (3rd page) - along with choosing the correct delimiter and text qualifier (2nd page).
No changes needed to the text file.
我更愿意在转换过程中直接解决这样的问题,通过给出正确的列格式,例如:对应包含操作符号的列使用 Text 格式:
检查此详细信息帖子:http://ask.osify.com/qa/854
I would prefer to solve such problem directly during the conversion, by giving the right column format, example: use Text format for the column that should contain operation sign:
Check this detail post: http://ask.osify.com/qa/854
查找并替换每个实例
<代码>+
和
' +
开头的单引号和空格应取消任何
+
、-
或=
。Find and replace every instance of
+
with
' +
A single quote and space at the beginning should cancel out any
+
,-
, or=
.您还需要将 1.5 数字转换为 1,5 字符串,这样它们就不会更改为日期类型值。
对于 + - = 我使用空格方法“+....” - 不太好,但对于我的任务来说已经足够了。
You also will need to transform 1.5 numbers to 1,5 strings, so they don't changed to date type values.
For + - = I use space method " +...." - not great, but for my task was enough.