Last active
May 2, 2018 12:09
-
-
Save acnagy/1f473d38d09a96383662b5d52820230b to your computer and use it in GitHub Desktop.
reconcile email csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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