From 79bbb023884881a6b62fb51078a75c1092e7f8c0 Mon Sep 17 00:00:00 2001 From: Steve Dogiakos Date: Tue, 1 Apr 2025 22:17:18 -0600 Subject: [PATCH] Updated guestbook_export.py so that the export --- scripts/guestbook_export.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/guestbook_export.py b/scripts/guestbook_export.py index 21bf00b..2cc11a2 100644 --- a/scripts/guestbook_export.py +++ b/scripts/guestbook_export.py @@ -1,24 +1,25 @@ import csv import sqlite3 +# Update the database file path if needed. DATABASE = 'guestbook.db' EXPORT_FILE = 'mailchimp_export.csv' def export_guestbook_to_csv(): conn = sqlite3.connect(DATABASE) cursor = conn.cursor() - # Select only entries that have an email address (if that's required) + # Select only entries that have an email address, if that's required. cursor.execute(''' - SELECT email, first_name, last_name + SELECT email, first_name, last_name, comment FROM guests WHERE email IS NOT NULL AND email <> '' ''') rows = cursor.fetchall() - with open(EXPORT_FILE, 'w', newline='') as csvfile: + with open(EXPORT_FILE, 'w', newline='', encoding='utf-8') as csvfile: writer = csv.writer(csvfile) - # Write headers matching Mailchimp's expected column names - writer.writerow(['Email Address', 'First Name', 'Last Name']) + # Write headers matching Mailchimp's expected column names (and including comment) + writer.writerow(['Email Address', 'First Name', 'Last Name', 'Comment']) for row in rows: writer.writerow(row)