Skip to content

Instantly share code, notes, and snippets.

@acnagy
Last active May 2, 2018 12:09
Show Gist options
  • Save acnagy/1f473d38d09a96383662b5d52820230b to your computer and use it in GitHub Desktop.
Save acnagy/1f473d38d09a96383662b5d52820230b to your computer and use it in GitHub Desktop.
reconcile email csv
# usage: python3 unsubscribe_clean-up.py emails-to-contact.csv unsubscribers.csv
import csv
import sys
email_file = sys.argv[1]
unsubscribe_file = sys.argv[2]
unsubscribes = []
with open(unsubscribe_file, "r") as unsubscribe:
for row in csv.DictReader(unsubscribe):
unsubscribes.append(row['email'])
with open('reconciled-emails.csv', 'w+') as reconciled_emails:
for row in csv.reader(open(email_file, "r")):
out = csv.writer(reconciled_emails)
if row[2] not in unsubscribes: # match based on email
out.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment