Python code to spot csv differences is not cooperating

Viewed 37

the code I have currently responds to.

# find differences to find Unique IDs Missing from Current Project Plan
def Diff(newlist, oldlist):
    li_dif = [i for i in newlist + oldlist if i not in newlist]
    return li_dif
#write the differences to a text file
li3 = Diff(newlist, oldlist)
with open(r'thepath\changelog.txt', 'w') as filehandle:
    filehandle.write('Unique IDs Missing from Current Project Plan\n\n')
    for listitem in li3:
        filehandle.write('%s\n' % listitem)
print('wrote differences to text file')
# find differences to find Unique IDs Missing from Old Project Plan
def Diff(newlist, oldlist):
    li_dif2 = [i for i in newlist + oldlist if i not in oldlist]
    return li_dif2
#append the differences to existing text file
li4 = Diff(newlist, oldlist)
with open(r'\\NGMOW8AJAAA4501\GIS_Projects\6_OTHER_SITE_DATA_AND_PROJECTS\Map Requests\2022_06_Real_Property_Working_Group_Dashboard\changelog.txt', 'a') as filehandle:
    filehandle.write('\n\nUnique IDs Missing from Old Project Plan\n\n')
    for listitem in li4:
        filehandle.write('%s\n' % listitem)
print('wrote differences to text file, task is completed')

my problem is the values in the new spreadsheet are the same as the old spreadsheet. I currently don't know how to fix it to reflect difference in values. Thank you and kind regards.

0 Answers
Related