Created
May 12, 2025 02:38
-
-
Save cohnt/6b37370256f9eaec1fd2fd66286e70c5 to your computer and use it in GitHub Desktop.
Filter Out Emails of People Who RSVPed Yes (Aisle Planner)
This file contains hidden or 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
import csv | |
# File paths (change these if needed) | |
parties_file = 'parties.csv' | |
guests_file = 'guests.csv' | |
output_file = 'yes_rsvp_emails.txt' | |
# Step 1: Collect RSVP IDs for guests who RSVPed yes | |
yes_rsvp_ids = set() | |
with open(guests_file, newline='', encoding='utf-8') as gfile: | |
reader = csv.DictReader(gfile) | |
for row in reader: | |
if row['Response'].strip().lower() == 'attending': | |
yes_rsvp_ids.add(row['RSVP ID']) | |
# Step 2: Collect emails from parties.csv for matching RSVP IDs | |
emails = set() | |
with open(parties_file, newline='', encoding='utf-8') as pfile: | |
reader = csv.DictReader(pfile) | |
for row in reader: | |
if row['RSVP ID'] in yes_rsvp_ids: | |
email = row['Email'].strip() | |
if email: | |
emails.add(email) | |
# Print results | |
for email in sorted(emails): | |
print(email + ",") | |
# Step 3: Write to output file | |
with open(output_file, 'w', encoding='utf-8') as outfile: | |
for email in sorted(emails): | |
outfile.write(email + ',\n') | |
print(f"Saved {len(emails)} email(s) to '{output_file}'.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment