Compare 2 seperate csv files and write difference to a new csv file - Python 2.7

后端 未结 3 1243
南旧
南旧 2021-01-26 05:21

I am trying to compare two csv files in python and save the difference to a third csv file in python 2.7.

import csv

f1 = open (\"olddata/file1.csv\")
oldFile1         


        
3条回答
  •  遥遥无期
    2021-01-26 05:52

    The error is correct: tuple has no "difference" method.

    I guess you want to use set (and make the elements immutable)?

    set1 = set([tuple(item) for item in oldList1])
    set2 = set([tuple(item) for item in oldList2])
    

提交回复
热议问题