Word DOCX From Template | Python
#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 :
? https://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 : https://youtu.be/uVPc9As7Kkw
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 ?
? https://www.patreon.com/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)
☕ https://www.buymeacoffee.com/DrPi ☕
Subscribe to the YouTube Channel
=================================
? https://www.youtube.com/c/DrPiCode
Follow on Twitter - to get notified of new videos
=================================================
? https://twitter.com/RngWeb
Thumbs up yeah? (cos Algos..)
docxtpl
docx
word docx
python
jinja2
docx from csv
#docx #tutorials #python
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Word DOCX From Template | Python», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.