I have a functioning script to generate multiple word documents based on an input of variables and a template. What I want to do is create one single word document with all of the templates appended.
Here is my current code:
from docxtpl import DocxTemplate
import pandas as pd
doc = DocxTemplate("template.docx")
df = pd.read_csv("input.csv")
for index, row in df.iterrows():
context = {'field1': row['field1'],
'field2': row['field2'],
'field3': row['field3'],
'field4': row['field4']}
doc.render(context)
doc.save(f"generated_doc_{index}.docx")