This tool aims to fill variables (of a given dataset input) into Merge Fields of a Microsoft Word template using Mail Merge library in Python. The main features are:
- Fill/populate Merge Fields from a Microsoft Word file (.docx) from a given dataset (an example is provided in the business-card-generator.py code).
- In case of more than 10 rows are contained in the input dataset, the template is replicated into multiple pages.
Two Microsoft Word (.docx) templates are provided:
- Wedding Business Card Template (required font: Angella White Font).
python -m pip install docx-mailmerge openpyxl pandas
business_card_generator(df, template, output_name)
- Fill variables (of a given dataset input) into Merge Fields of a Microsoft Word template.
df
: DataFrame. The DataFrame should include a name column, with the names that will be inserted to the Word template file.template
: str, path object or file-like object. Word template input file.output_name
: str, path object or file-like object. Output of the transformed Word template input file.