我有一个 CSV 文件:
101, "Name1", "Designation1", "blah1", "Blah1", 20200914001
102, "Name2", "Designation2", "blah2", "Blah2", 20200914002
103, "Name3", "Designation3", "blah3", "Blah3", 20200914003
104, "Name4", "Designation4", "blah4", "Blah4", 20200914004
105, "Name5", "Designation5", "blah5", "Blah5", 20200914005
将每一行替换如下:
101|| "Name1", "Designation1", "blah1", "Blah1"|| 20200914001
类似的结构也适用于其余的行/记录。
我的代码替换了所有分隔符。
data = ""
with open('firstCSV.csv', 'r') as file:
data = file.read().replace(',', '||').replace(' ', '')
with open("first_Out.csv", "w") as out_file:
out_file.write(data)
提前致谢。
繁星coding
隔江千里
相关分类