import re
f = open("strangeFile.csv", "r")
lines = f.read().splitlines() #split file into a list of lines
f.close()
for line in lines:
items = line.split("\",\"") #split by 'strange' delimiter
line = " ".join(items) # join with a space, comma or tab
line = re.sub("^\"|\"$","",line) #remove open and close quote marks
print(line)
#append line to a new csv file
1条答案
按热度按时间3hvapo4f1#
我想你是说“,”是这个文档中的分隔符,你想清理数据。
以下代码将打印:
然后可以将输出附加到“干净”CSV文件。