#Automation #Python #CSV #DOCX
Over a year ago I was asked to create 100+ almost identical word documents as "workplans" for my day job (They did not know I use Python to get things done). Writing multiple word documents and copy and pasting location, date, and contact details from a CSV was not what I had in mind.
Although I was a senior network engineer my boss seemed to think I would enjoy this highly repetitive task. I said it would take days, in the end it took about an hour to write the code and 5 seconds to generate 150 word documents (DOCX).
Automating the creation of these almost identical word documents was made possible with Python, docxtpl, and 1x word 'template' - (which was essentially a word doc with curly braces around the bits that are unique within the document).
👍 If you want a fast VPS server with Python installed check out :
🌏 webdock.io/en?maff=wdaff--170
◼️◼️◼️ (note when I say template it is still : "DOCX" not "DOTX") ◼️◼️◼️
------------------------------------------------------------------------------------------------------------
I never expected the original video to be so popular, so I have remade it, using Windows, with newer and hopefully clearer explanations, and a full csv source file.
If you like this tutorial, or if it has saved you hours of your life please let me know as automating repetitive tasks with Python is very pleasing. It's the ultimate 'revenge' when an employer expects you to sit there and do it manually!
► The code here is written in Windows as opposed to Ubuntu in my earlier version of this video seen here : • Python code to dynamic...
Seeing as I was rewriting it I thought I'd do it for M$ Windows.
► If you use Mac, or Linux, you'll need to edit the file path syntax to suit.
► If you don't have M$ Office then "Libre" or "Open" Office will work just the same.
Become a patron 👍
🌏 / drpi
-- chapter timings --
---------------------------------
0:00 Introduction
01:00 pip instal docxtpl
04:07 Starting code
07:31 The CSV values for the Jinja placeholders
12:26 split the row to get individual values
16:45 149 word documents in 5 seonnds
-----------------------------------------------------------------------------
=================================================
Buy Dr Pi a coffee (or Tea)
☕ www.buymeacoffee.com/DrPi ☕
Subscribe to the RU-vid Channel
=================================
🌏 / drpicode
Follow on Twitter - to get notified of new videos
=================================================
🌏 / rngweb
Thumbs up yeah? (cos Algos..)
docxtpl
docx
word docx
python
jinja2
docx from csv
#docx #tutorials #python
5 авг 2024