如何显示逗号分隔符 [英] How Do I Show A Comma Deliminator

查看:128
本文介绍了如何显示逗号分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我目前正在尝试将数据从我的数据库导出到CSV文件。



问题我我有一个用户有时输入的描述字段,在描述中(例如这是我的描述,测试)



所以当我出口时它是在描述中添加时创建一个新字段



是否可以保留,在描述中是否如此?

Hi
I am currently trying to export data from my database to a CSV file.

The problem i am having is i have a description field which the users sometimes enter , in the description(e.g. "this is my description,test")

so when i do my export it is creating a new field when the , is added in the Description

is it posible for me to keep the , in the description if so how?

推荐答案

是:CSV允许:用双引号括起数据:

Yes: CSV allows for that: just surround the data with double quotes:
123,"this has no problem","this would, though", 456



根据你用来创建CSV文件的内容,它应该自动为你做,但如果你正在生成他们自己,然后不要忘记在用户输入中处理双引号加倍双引号!


Depending on what you are using to create the CSV file it should do it automatically for you, but if you are generating them yourself, then don't forget to process double quotes in user input to double-double quotes!

123,"this has no problem","this ""would"", though", 456

如果您选择逗号作为CSV文件的分隔符,那么您有几种方法可以解决您的问题:



1)使用另一个分隔符你的CSV文件(例如,制表(\ t),分号(;)等。)。



2)用双引号括起你的字段;这样,逗号将被识别为字符串的内部成员,而不是分隔符。



希望这会有所帮助。
If you chose the comma as delimiter for your CSV file, then you have several options to circumvent your problem :

1) Use another delimiter for your CSV file (for example, tabulation ("\t"), semicolon (";"), etc.).

2) Enclose your fields between double-quotes; this way, the comma will be recognized as an internal member of the string, rather than as a delimiter.

Hope this helps.


这篇关于如何显示逗号分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆