Mail Merge
🌐 English · Dansk · Bahasa Melayu
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
- Reads the guest names from
Input/Names/invited_names.txt with readlines().
- Reads the letter template from
Input/Letters/starting_letter.txt.
- For each name, removes the trailing newline with
strip() and swaps the [name] placeholder with replace().
- Writes the result to
Output/ReadyToSend/letter_for_<name>.txt.
Folder layout
How to run
From the project root:
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 |