Skip to content

Instantly share code, notes, and snippets.

@crmpicco
Created February 20, 2023 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crmpicco/dcd5d9602ae372a35afb3647241310e9 to your computer and use it in GitHub Desktop.
Save crmpicco/dcd5d9602ae372a35afb3647241310e9 to your computer and use it in GitHub Desktop.
De-dupe the signup email send list with the send list export from Sendy
#!/usr/bin/python
# De-dupe the signup email send list with the send list export from Sendy
import os
import sys
import csv
import pprint
signup_emails = []
signup_send_list = {}
with open('~/Mandrill/edm-export-20200807.csv') as signup_fp:
reader = csv.reader(signup_fp, delimiter=',', quotechar='"')
for row in reader:
signup_emails.append(row[0])
signup_send_list[row[0]] = {
'name' : row[1],
'subdomain' : row[2]
}
mkt_emails = []
with open('~/Mandrill/edm-export-20200806.csv') as mkt_fp:
reader = csv.reader(mkt_fp, delimiter=',', quotechar='"')
for row in reader:
mkt_emails.append(row[1])
deduped_send_list = [elem for elem in signup_emails if elem not in mkt_emails]
with open('~/Mandrill/edm-20200806.csv', 'wb') as deduped_fp:
writer = csv.writer(deduped_fp, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
rows = 0
for deduped_email in deduped_send_list:
rows += 1
writer.writerow([deduped_email, signup_send_list[deduped_email]['name'], signup_send_list[deduped_email]['subdomain']])
print("Done. " + str(rows) + " rows written to file.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment