I have a script that scrapes a site and puts specific site names into a csv. Some days it has 0 site names and some days it has more the 4. I have another script that takes the csv from today and the csv from yesterday and compares the two. If today's csv has site names that were also on yesterday's csv I want to outfile those site names to a different txt file. I have:
with open(filepath + today + filename, 'r') as t1, open(filepath + yesterday + filename, 'r') as t2:
fileone = t1.readlines()
filetwo = t2.readlines()
with open(checklistFile, 'w') as outfile:
for line in fileone:
if line in file:
outfile.write(line)
print("bad")
else:
outfile.write("good")
print("good")
this only works if the csvs have the same number of lines and only works if they are in the same order. For instance, if today had "site1, site2, site3" and yesterday had "site4, site1, site5", this script would miss it. Any help would be appreciated. I'm running Python 2.7 so I cant use csv-diff.