小编Sop*_*e.K的帖子

python csv 到 tsv:如果记录里面有逗号

我正在尝试将 csv 格式转换为 tsv。我只是用它来将逗号更改为制表符。

tsv = re.sub(',', '\t', csv)

但我无法处理里面有逗号的字符串,例如:

dept_no,dt,hello
1,20180411,hello its me
2,20180412,here has tab
3,20180412,"here, is, commas"
Run Code Online (Sandbox Code Playgroud)

有没有什么方法可以转换为 tsv 而不影响字符串内部的逗号?

python csv

0
推荐指数
1
解决办法
3597
查看次数

标签 统计

csv ×1

python ×1