当.CSV的值之一可能在字符串中包含逗号时,请处理 [英] handling .CSV when one of it's value may include a comma in the string

查看:214
本文介绍了当.CSV的值之一可能在字符串中包含逗号时,请处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.csv,我需要将其转换为Coldfusion查询.我使用了cflib.org CSVtoQuery方法,该方法可以正常工作...但是...

I have a .csv that I need to convert to a coldfusion query. I have used the cflib.org CSVtoQuery method which works fine... but...

如果csv中的单元格"在字符串中包含逗号(例如列表),则该记录的查询行会被弄乱,因为它将字符串中的逗号视为新值.

If there is a 'cell' in the csv that includes a comma in the string, such as a list, the query row for that record gets messed up as it sees the comma in the string as a new value.

我无法控制数据的输入方式,因此无法将其编写或传递给引号之类的内容.

I have no control over how the data is going in, so I can't have it written or passed inside quotes or the like.

有人知道是否有一种方法可以处理可能在值中带有逗号的.csv(转换为查询或其他可行的结构)吗?

Does anyone know if there is a way to process a .csv (convert to a query or other workable struct) that may have commas in the values?

推荐答案

不,没有.制作CSV的人无法正确制作.如果没有办法分辨不同的逗号,则没有CSV解析器无法分辨分隔的逗号和没有分隔的逗号之间的区别.

No, there isn't. Whoever is making the CSV is not making it properly. No CSV parser can tell the difference between commas that separate and commas that don't if there is no way to tell the difference.

创建文件的人应选择其他定界符.

Whoever is making the file should choose a different delimiter.

这篇关于当.CSV的值之一可能在字符串中包含逗号时,请处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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