mail_merge
Generate a filled .docx for each data row from a template, using CSV, JSON, or a list. Saves personalized documents to an output directory, preventing overwrites and reporting missing values.
Instructions
Mail merge: one filled .docx per data row, saved into output_dir. data_rows: a list of dicts, or a path to a .csv (header = placeholder names) or .json (array of objects). filename_pattern supports {row_index} (1-based) and any {column}. Refuses BEFORE writing anything on existing-file collisions, duplicate output names, or (missing='error') rows lacking values the template needs. The template is never modified.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| missing | No | error | |
| data_rows | Yes | ||
| output_dir | Yes | ||
| template_path | Yes | ||
| filename_pattern | No | {row_index}.docx |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||