我有一个示例csv文件包含
col1
"hello \n
world"
"the quick \njump
\n \r \t brown fox"
转换为tsv的示例代码
import pandas as pd
df = read_csv(r'a.csv')
df.to_csv('data.tsv', sep='\t', encoding='utf-8', escapechar='\n')
预期结果将是
col1
"hello \n world"
"the quick \njump \n \r \t brown fox"
但结果是
col1
"hello \n
world"
"the quick \njump
\n \r \t brown fox"
在阅读csv时使用
escapechar
对我来说很有效。但它在转换为tsv时跳过了双引号输出:
相关问题 更多 >
编程相关推荐