如何在csv文件中用逗号分隔值? [英] How to separate values with a comma in a csv file?

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

问题描述

Ex,'x,y'在一个单元格中。 X和y对于每一行都是不同的值,这就是为什么我不能用x,y来写逗号。



我试过的:



https://docs.python.org/3/library/csv.html

解决方案

CSV代表 C omma S eparated V alues - 这意味着逗号分隔两个值,因此1,56将被解释为两个值(两个单元格)......

正如它在CSV定义中所述:

引用:
6。包含换行符(CRLF),双引号和逗号

的字段应括在双引号中。例如:



aaa,b CRLF

bb,cccCRLF

zzz ,yyy,xxx



https://tools.ietf.org/html/rfc4180 [ ^ ]


Ex, 'x, y' in one cell. X and y will be different values for every row, that is why I cannot do "x, y" to write a comma.

What I have tried:

https://docs.python.org/3/library/csv.html

解决方案

CSV stands for Comma Separated Values - it means that a comma separate two values, so 1,56 will be interpreted as two values (two cells)...
As it stated in CSV definition:

Quote:

6. Fields containing line breaks (CRLF), double quotes, and commas
should be enclosed in double-quotes. For example:

"aaa","b CRLF
bb","ccc" CRLF
zzz,yyy,xxx


https://tools.ietf.org/html/rfc4180[^]


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

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