#!/usr/bin/env python3 """ Mark a bounced email address as skip in contacts/master.csv Usage: python3 mark_bounce.py email@example.com [email2@example.com ...] """ import csv, sys from pathlib import Path CONTACTS = Path(__file__).parent / 'contacts' / 'master.csv' def mark_bounced(emails): emails = [e.strip().lower() for e in emails] rows = [] marked = [] with open(CONTACTS, newline='') as f: reader = csv.DictReader(f) fieldnames = reader.fieldnames for row in reader: if row['email'].strip().lower() in emails: row['skip'] = 'yes' row['notes'] = (row.get('notes','') + ' [BOUNCED]').strip() marked.append(row['email']) rows.append(row) with open(CONTACTS, 'w', newline='') as f: writer = csv.DictWriter(f, fieldnames=fieldnames) writer.writeheader() writer.writerows(rows) for e in marked: print(f'✓ Marked as skip: {e}') missed = [e for e in emails if e not in [m.lower() for m in marked]] for e in missed: print(f'✗ Not found in contacts: {e}') if __name__ == '__main__': if len(sys.argv) < 2: print('Usage: python3 mark_bounce.py email@example.com [email2 ...]') sys.exit(1) mark_bounced(sys.argv[1:])