From c4a58858e3b1a3a72b18ff5c55e4fb8c6ffa4bcd Mon Sep 17 00:00:00 2001 From: Jens Tirsvad Nielsen Date: Tue, 13 Oct 2026 14:18:38 +0800 Subject: [PATCH] Add Home page --- Home.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Home.md diff --git a/Home.md b/Home.md new file mode 100644 index 0000000..85ccb8e --- /dev/null +++ b/Home.md @@ -0,0 +1,45 @@ +# Mail Merge + +A small Python script from the Udemy *100 Days of Code* course (day 24). It turns one letter template and a list of names into one personalised letter per name. + +## What it does + +1. Reads the guest names from `Input/Names/invited_names.txt` with `readlines()`. +2. Reads the letter template from `Input/Letters/starting_letter.txt`. +3. For each name, removes the trailing newline with `strip()` and swaps the `[name]` placeholder with `replace()`. +4. Writes the result to `Output/ReadyToSend/letter_for_.txt`. + +## Folder layout + +``` +main.py +Input/ + Names/invited_names.txt one name per line + Letters/starting_letter.txt template containing [name] +Output/ + ReadyToSend/ generated letters +``` + +## How to run + +From the project root: + +```bash +python main.py +``` + +The `Output/ReadyToSend/` folder must exist before you run it. It is created in the repository and contains the generated letters. + +## Adapting it + +- **Different guests:** edit `Input/Names/invited_names.txt`, one name per line. +- **Different letter:** edit `Input/Letters/starting_letter.txt` and keep the `[name]` placeholder. +- **Different placeholder:** change `PLACEHOLDER` at the top of `main.py`. + +## Python methods used + +| Method | Purpose | +| --- | --- | +| `readlines()` | Read all names from a file into a list | +| `strip()` | Remove the newline and surrounding whitespace from each name | +| `replace()` | Substitute the placeholder with the name |