Skip to content

Instantly share code, notes, and snippets.

@lyhistory
Created December 28, 2018 01:50
Show Gist options
  • Save lyhistory/f4fb3f4e07f5d64bdb188863a703a7d3 to your computer and use it in GitHub Desktop.
Save lyhistory/f4fb3f4e07f5d64bdb188863a703a7d3 to your computer and use it in GitHub Desktop.
import csv
f1 = file('1.csv', 'r')
f2 = file('2.csv', 'r')
f3 = file('results.csv', 'w')
c1 = csv.reader(open("1.csv", 'rU'), dialect='excel')
c2 = csv.reader(open("2.csv", 'rU'), dialect='excel')
c3 = csv.writer(f3)
masterlist = list(c2)
for hosts_row in c1:
row = 1
row2 = 0
found = False
for master_row in masterlist:
results_row = hosts_row
if hosts_row[1] == master_row[8]:
results_row.append('FOUND in master list (row ' + str(row) + ')')
found = True
break
row2 = row2 + 1
row = row + 1
if not found:
results_row.append(str(row)+' NOT FOUND in master list')
c3.writerow(results_row)
f1.close()
f2.close()
f3.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment