Search code examples
pythontemplatesautomationms-worddocument

How to automate word document from Json data using python


I have a JSON file. How can I create a word document from JSON data. Using templates, I can only fill in one variable. How do I create dynamic word template based on number of values inside JSON list? For Ex. if I have 10 values in a list, I want my word template to automatically multiply one row into 10 rows and then fill in the values for those 10 rows.


Solution

  • I solved it by using python DOCXTPL library. I created a template docx file using Jinja template and dynamically rendered JSON data.