This Python project automates the creation of personalized letters using a mail merge technique. It reads a list of names and a letter template, then generates custom letters for each name by replacing placeholders in the template.
- Reads names from a
.txtfile - Loads a letter template containing placeholder
[name] - Replaces the placeholder with each person's name
- Saves the output letters as
.docxfiles in a target folder - Efficient use of file handling and string replacement
- The program reads a file of names (
invited_names.txt). - It also loads a template letter (
starting_letter.txt) that contains[name]as a placeholder. - For each name, it:
- Removes any whitespace
- Replaces
[name]with the actual name - Saves the result as a new file:
letter_for_<Name>.docxin theOutput/ReadyToSendfolder
📁 Input ├── 📁 Names │ └── invited_names.txt └── 📁 Letters └── starting_letter.txt 📁 Output └── 📁 ReadyToSend └── letter_for_.docx
- Python 3
- File I/O
- String manipulation
- Looping & logic
- Clone the repository
- Replace the invited_names.txt and starting_letter.txt with your own data.
- Run the script:
- main.py
- This project is open source and available under the MIT License.