Sitemap
Learn With Mohit Vyas

Learn With Mohit Vyas

Hi I'm Mohit Vyas, a tech enthusiast, exploring cloud, AI, data engineering, and tech trends — with Google Cloud AI Data Engineering lens.

Document creation using Python

3 min readFeb 7, 2026

Today we will be talking about how to create documents using Python.

Press enter or click to view image in full size
Photo by Bernd Klutsch on Unsplash

Recently, I came across a requirement where we had to create reporting solution using Python. We explored many options like inbuilt tools and the other external vendor tools, but they were coming with a cost. So what we finalized is what we’ll see now.

Let’s assume you have data coming from different sources and you are curating the data into a layer which you call as the data lake or the cloud data warehouse. And then from that warehouse or the data lake, you have to create documents or reports or any such thing which can be viewed by the leadership. So what will you do in that case? How will you automate the entire process? That is what we’ll be talking about in this article.

Get Learn With Mohit Vyas’s stories in your inbox

Join Medium for free to get updates from this writer.

In order to create any document, report, or any such thing from the data which is present in your cloud data warehouse or data lake, you’ll have to first know what kind of document to create or the structure of the document to be rendered or created which is called a template.

Press enter or click to view image in full size
Feuille de notation produit cannabis et CBD customisable avec votre logo ou vos informations
Photo by Testeur de CBD on Unsplash

Once you have the template or the structure of the document which is to be created, you would need something as the intermediate copy of the data, which can be in any form or format, let it be XML or JSON. Now you have the template ready and also the data which is to be rendered in the template. What next? The next is the mapping of the data present in the JSON or the XML with the template.

Press enter or click to view image in full size
Code example of JSON file
Photo by Ferenc Almasi on Unsplash

Once you know which data is to be placed at which position in the template or the final document, you’ll be having the placeholder in place in the template. Each placeholder will be mapped one-to-one with the data which is present in your XML or JSON file. Once all the elements of the JSON or the XML file are mapped with the template in the form of placeholders, you are ready to finalize your template.

In order to render the data present in XML or JSON onto the template to create the final document, we’ll be using native Python libraries. One such library, which is natively available in Python is Docxtpl. You can use this library and its functions in order to generate the final target document from the data which is available in your JSON or XML.

Press enter or click to view image in full size
Photo by Rubaitul Azad on Unsplash

--

--

Learn With Mohit Vyas
Learn With Mohit Vyas

Written by Learn With Mohit Vyas

Hi I'm Mohit Vyas, a tech enthusiast, exploring cloud, AI, data engineering, and tech trends — with Google Cloud AI Data Engineering lens.