Excel在CSV导出中添加额外的报价

编程入门 行业动态 更新时间:2024-10-13 20:20:33
本文介绍了Excel在CSV导出中添加额外的报价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我最近创建了一个应用程序,该应用程序通过CSV将项目添加到数据库中.添加项目后,我意识到很多值都不需要多余的引号(),这使我的订购变得混乱.

I've recently created an application which adds items to a Database by CSV. After adding items I realized that lots of my values had extra quotes (") that weren't needed and this was messing up my ordering.

问题在于,当从Excel导出到CSV时,Excel会将多余的引号添加到我所有已带有引号的值中.我已经显示出以下差异:

The problem is that when exporting to a CSV from Excel, Excel adds extra quotes to all of my values that already have a quote in them. I've shown the difference below:

原始产品:可逆电钻1/2"6.3A

出口商品:可逆电钻1/2""6.3"

请注意:CSV导出会添加三(3)个额外的引号().两端加两个引号,一个在原始预期引号之后.

是否可以在Excel文件/列上更改设置或设置格式属性?还是我必须忍受它并在添加到数据库之前在我的后端代码中删除这些引号?

Is there a setting I can change, or a formatting property I can set on the Excel File/Column? Or do I have to live with it and remove these quotes in my back-end code before adding them to the Database?

推荐答案

这是完全正常的.添加外部引号,因为这是一个字符串.内引号被加倍以逃避它.例如,您在SQL查询中会看到相同的内容.使用TextFieldParser类可以为您自动尝试真正的框架代码解析.

This is entirely normal. The outer quotes are added because this is a string. The inner quote is doubled to escape it. Same kind of thing you'd see in a SQL query for example. Use the TextFieldParser class to have tried and true framework code care of the parsing of this for you automatically.

更多推荐

Excel在CSV导出中添加额外的报价

本文发布于:2023-05-28 06:58:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/315169.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Excel   CSV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!