【发布时间】:2020-07-21 23:50:18
【问题描述】:
我有一个脚本,它比较 2 个 csv 文件并将数据输出到一个新的 CSV 文件。 我正在寻求帮助,以便能够将新输出文件中的数据附加到相同代码中的 allhistory 文件中。有人建议使用什么吗?
import csv
with open('allhistory.csv', 'r') as t1, open('filewithnewdata.csv', 'r') as t2:
fileone = t1.readlines()
filetwo = t2.readlines()
with open('update.csv', 'w') as outFile:
for line in filetwo:
if line not in fileone:
outFile.write(line)
【问题讨论】: