*I will be here in the comments section. If you have any questions, please let me know.* Quick note: At 06:42 min, the Word document's date is different compared to the Excel screenshot. Reason: I have edited the video a couple of days after the initial recording. When I took the screenshot from the Excel file, I did not adjust the 'today' formula. This is causing the 'difference'.
How about combining multiple text files together into one, like a table of contents and heading sections all saved as separate files? Part of the goal is to avoid tracking down all the places a boilerplate has been used, versus changing a the boilerplate in a central file and having that update in every file that includes it. The other part is to have more granular version control and to make it easier to handle a document - to just hold a chapter at a time, rather than a whole book. Cheers, thanks for your thoughts and your videos! Your channel is the most important and valuable to my work. I don't have users looking for me to code apps for them; I just have a ton of "office suite" tasks to achieve, with not enough time, and I hate the idea of wasted time and effort. Thanks again.
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Hey, thanks for the great video it helped me alot! I have a question regarding strfime(). I want to have alterneting time formats for the same placeholder and want ask if thats possible. So lets say for the first row its (%y %m %d) then for the second row (%d %m %y) and then third row the same as first… would this be possible? Thanks for any help!
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you! -Sven
Very useful video. Thank you. How can we transfer data from multiple Excel sheets to a Word file? Do you have a video? I would be very happy if you could help.
Thanks for watching. Yes, that is absolutely possible. You might want to check out the xlwings package. That said, I cannot provide you an examples, as I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Great tutorial. Thank you very much. As for the dates, I noticed the output in the word document is 11-02-2022 and this is different from the dates in the excel file. How can I fix that?
Good catch. I have edited the video a couple of days after the initial recording. When I took the screenshot from the Excel file, I did not adjust the 'today' formula. Hence, the date is not the same. I hope this clarifies.
@@KhalilYasser The output is based on the Excel file. When I saved the Excel file, it was 2022/02/11. Open the Excel file, check today's date and save the file. Afterwards, rerun the script. Alternatively, use the DateTime module directly in the Python script, as shown in the video. I hope this helps!
Fantastic explanation. For example, however, users don't have the columns with "NAME, VENDOR, AMOUNT, NONREFUNDABLE....". They have columns with different names? How can we solve that? You can guide the way to code to adapt with variable names with column? Thanks a lot!
Thank you for watching. As outlined in the video, you would need to adjust the column headers (names) to suit your specific needs. Just make sure that the column header names match the placeholders in Word. I hope this information is helpful. Happy coding!
Love your content. It’s very clear and well explained. I was hoping you can help me. I need to create a table in the document, dynamically with hiding rows and columns based on if values exist in the excel data source. How can I modify this solution to create and add tables?
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
hi extremely helpful video but is there any way to insert a placeholder of an excel column that has both text and dates in word facing the issue of for dates it shows time as well which i dont want
Thanks for watching. Try out the following: df["TODAY"] = pd.to_datetime(df["TODAY"]).dt.strftime('%d.%m.%Y') df["TODAY_IN_ONE_WEEK"] = pd.to_datetime(df["TODAY_IN_ONE_WEEK"]).dt.strftime('%d.%m.%Y')
Hello! I am getting an error 'pip' is not recognized as an internal or external command, operable program or batch file. Any idea how to fix it? and do you have any beginners videos?
Hi Sven, i was wondering if you could help me create multiple excel files, each containing details of different customers, using the same procedure as shown in this video. Same placeholder technique but for excel. Would be great help, Sven. Thanks
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
What interests me most at the moment is 1) creating the rubric of a contract for different parties who work together (party, address, executing department, PI, address of the department. The number of parties should be selectable. That means for example: 10 parties in the rubric. I need a GUI where I type in how many parties and give each party various attributes, like the one listed above. 2) creating 1 single page for the signature of 1 party - which consist of the PI and the head of the legal office / chief of (...). That means for example: 10 parties listed above as a head line, 10 signature pages for 20 people. This process is really exhausting and should not be done manually. Maybe this is easier said than done. Thanks in advance!
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
If I want to paste based on one column same records in 1 word file and based on another the same column the other records in another word file, how can we do that?
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
Hi, Excellent video. Is it possible to update a Word document with a picture of the tables from an Excel spreadsheet. The word documents will have bookmarks in various places for the tables. Thanks
Thanks! Are you using a Juypter Notebook? Try the following instead: base_dir = Path(__file__).parent if "__file__" in locals() else Path.cwd() I recommend watching the pathlib tutorial on my channel to understand the line. Happy Coding!
Great video! This allows me to pursue programmatic seo now (after I scrape my data)! I did have a problem with the __file___ for the directory path. It kept saying it wasn't defined, so I just omitted it from the code. I'm using Anaconda/Spyder Python 3.9 for coding if that helps solve it. Thanks!
Thanks for watching. Glad it was helpful. I have modified the base_dir path as follows ⤵ base_dir = Path(__file__).parent if "__file__" in locals() else Path.cwd() github.com/Sven-Bo/word-generator-based-on-excel-list/commit/b6e38a0925547d0ce0374835d5d5b4d086df8508 Thanks for pointing it out!
How can we modify the output to dump all the data at the same document? I was thinking in change the output to the same file but that will overwrite each time. Any ideas? Thank you and great video!
Thanks for watching the video. After creating the documents, you could merge them: eazytutorial.com/index.php/2021/08/13/merge-word-docs-python/ Happy Coding!
Hi sir. Is it possible to make GUI for this? If yes, is it possible to choose different excel files everytime I want to generate the documents? For example, I want to use the same docs template, but the data will be from the different excel file each time. Do you know how to make it work?
Nice work! Is it possible to automate document generation incorporating different level bullets? My template has a table with a bullet and iterates over the inputs. Some are bullet level one, some go to bullet level 2. But it is all bullet level one when brought over to the template.
Thank you for watching the video and for your question. Unfortunately, I do not know how to implement that right off the bat. I would also need to search the internet for a solution. Sorry that I cannot help!
Have a look at the following blog to learn how to format numbers in Python: queirozf.com/entries/python-number-formatting-examples I hope it helps! Happy Coding!
I was wandering here and there for a decent video but I came across your channel and it blew my mind. Thank you for the awesome videos you post. Is it possible to create a python script which will take inputs as form from us in GUI and then save them to excel and return the output in notepad and open the file? Highly appreciated if I can get a response.
Happy to hear that you are enjoying the videos. Regarding your questions, you could use the following solution as a starting point: th-cam.com/video/svcv8uub0D0/w-d-xo.html I hope it helps! Happy Coding!
Now that I write python code on the web online, is it possible to do something like this video without installing an IDE? Ps: look at your proton orbiting electron icon file .py, are you using the Atom IDE? I plan to use the Pycharm IDE
Thanks for watching. You can use whatever text editor / IDE you want. Also, in general you could run the code online, but I cannot explain the entire concept in a single comment. The best way would be to try it out yourself. In that way, you will also learn a lot of things along the way. Happy Coding!
Is that possible to change "doc = DocxTemplate(word_template_path)" that program use another Template if row contain NaN values? I mean for that row where is "NaN" - use another 'DocxTemplate' ex.: creating 2 Template word file use template2 just for that row (where has NaN value) to create word document
Yes, it is possible by inserting the respective if conditions. Yet, I am missing the time to code out an example for you. Thanks for your understanding!
Great video! :) Also, I'm looking into based on a specific field/values from the Excel sheet, how to modify/set the values of radio buttons (to Yes/No) in the Word document?
Thank you for watching the video and for your question. Unfortunately, I do not know how to implement that right off the bat. I would also need to search the internet for a solution. Sorry that I cannot help!
Is it possible to create an unknown amount of place holders? Example i have a list of products, an then a list of all customers who purchased from lets say 2021. Is it possible to create a word doc to each customer containing all SKU's they bought from the list of products similar to your example but with multiple placeholders?
Thanks for watching. You might want to include a table which will be expanded dynamically based on the variables you provide. Have a look at the following example: Code: github.com/elapouya/python-docx-template/blob/master/tests/dynamic_table.py WordTemplate: github.com/elapouya/python-docx-template/blob/master/tests/templates/dynamic_table_tpl.docx I hope it helps! Happy Coding!
Love your content as always. At work, I'm tasked with creating many PDFs from an excel template. I'm thinking of looping through a script that uses xlwings to implement the placeholder values that I'll pull from a dataframe. Do you agree with this approach or know of a better solution? Any suggestions on which package to use to export to PDF would be super useful too!
Hey there! I'm glad you're enjoying the content. Sounds like you're trying to create PDFs from an Excel template using xlwings. That approach should work well for you, as xlwings is a good package for working with Excel files in Python. You can use the following method to export the workbook to a PDF: docs.xlwings.org/en/stable/api.html#xlwings.Sheet.to_pdf I hope it helps. Happy Coding!
Thank you for watching the video and for your question. Unfortunately, I do not know how to implement that right off the bat. I would also need to search the internet for a solution. Sorry that I cannot help!
This is fantastic! My first Python Code! Thank you for this very useful tutorial. Sven, please could I ask how do I change the format from YYYY-MM-DD to DD-MM-YYYY in your script? Thank you!
Thanks for watching. Try out the following: df["TODAY"] = pd.to_datetime(df["TODAY"]).dt.strftime('%d-%m-%Y') df["TODAY_IN_ONE_WEEK"] = pd.to_datetime(df["TODAY_IN_ONE_WEEK"]).dt.strftime('%d-%m-%Y')
I managed to automate my process and automate word docs to be populated with values from csv file, but sometimes with some word files i keep on getting an error when trying to open a word doc i get 'The file cannot be opened because there are problems with the contents'
@codingisfun Dear Sven, have you ever done a project of creating a reference letter( zeugnis, zwischenzeugnis) using python or vba? I would love to see your variant of it. Normally an employer fills in a word template, which is then moved to an excel tool. At the end, in the tool you click Zeugniserstellung and the new doc gets generated.
I have not done exactly that kind of project, but similar ones. It is definitely possible with Python or VBA, but as with almost all coding projects, there is often no one-size-fits-all solution. So, you could take the code from the video as a starting point to create your own custom solution. Happy Coding!
Thanks for watching the video. That is possible. Option A: Keep all Excel columns and insert the placeholder you want (in word) Option B: In pandas, you can also select specific columns. Have a look here: pandas.pydata.org/docs/getting_started/intro_tutorials/03_subset_data.html I hope it helps!
Hey! In this Scenario we took particular excel for generating, but what if we want to take any excel and generate docs. We always cannot come and change the name of the excel in the code right. So could you please make a gui interface to pick the file from local files and generate docs? I hope you'd help. Thanks!
@@maneeshreddy7088 I do not have the time to code out an entire solution based on your needs. I hope you can understand that. That said, there are many Python modules available to develop a GUI. My favourite library is 'PySimpleGUI'. Perhaps the following video helps you to get started with PySimpleGUI: th-cam.com/video/svcv8uub0D0/w-d-xo.html Happy Coding!
Great as always. Is possible to add a table from a data frame or excel sheet? Can you do a video with powerpoint in future? For example reports for products or costumers on one sheet with two or three kpis per product or costumer. In my case I used groupby in pandas, get the sums and then must write this manually in powerpoint. And I have to add a logo as a png or jpg per product or customer.
Thank you, Mike! Yes, you can also inject data from Excel into your Word template. You might want to check out the following video, where I have done something very similar: th-cam.com/video/T3meVMaV8AA/w-d-xo.html Great video suggestion (PowerPoint automation)! I noted your idea, but I cannot make any promises. I hope you can understand. Thanks!
Really nice script! Can't praise it enough However.. Have you or anyone found a solution/stumbled upon the issue of images? Like if we want to apply images when rendering the documents. Ex. Link to image (preferably if possible, multiple images) in excel or similar?
Thanks for the kind words. You could also render images. Check out the following tutorial: th-cam.com/video/T3meVMaV8AA/w-d-xo.html I hope it helps! Happy Coding!
Thanks for the suggestion. Have a look at the following video/code. In one of my previous word automation videos, I have also included a function to save the output as a pdf file: github.com/Sven-Bo/python-word-automation I hope this helps!
Amazing ! thank you and GOD bless you for this sharing. but, please help me to turn it into an .exe file. I tried, everything seem to be ok, but the output folder is empty and i get error saying " no such file or directory". thank again and waiting for your feedback.
Thanks for watching. Please try to replace the following line: ❌base_dir = Path(__file__).parent if "__file__" in locals() else Path.cwd() with this: ✔ base_dir = Path.cwd() I hope it helps!
@@CodingIsFun Thank you a lot for your feedback. I've just tried, and now everything is ok. You are a blessed guy for me. You deserve more than 1M subscribers. I will share massively your channel to help you in this way. Thank again !
@@CodingIsFun Just a couple of questions: how can I save the word files with both vendor and client name? Now it’s just a vendor name. Also, I wanted to save the file as PDF. When I changed the .docx to .PDF, the acrobat reader couldn’t open it.
@@ahv5457 Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
Thanks for watching the video. After creating the documents, you could merge them: eazytutorial.com/index.php/2021/08/13/merge-word-docs-python/ Happy Coding!
Sir please help…. I want one doc file. By this code we are getting multiple files. Can you share any other/updated code for getting single document output. Please please sir repl
What do you mean by one output file? Should each word document be appended to each other? Please share some additional information and/or provide an example. Thanks!
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
After creating the Word documents, you can use the COM interface to open Word and print the document. Have a look here: darkcoding.net/software/printing-word-and-pdf-files-from-python/
Thanks for watching! You can use PyInstaller to create an executable file of your script, making it easy for your team to use without needing Python installed
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Hi, thank you for sharing. When i tried to replicate with a different table, I keep meeting this challenge. "ValueError: file 'input.xlsx' is not a Word file, content type is 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml' Not sure what is causing that. Thank you
Thanks for watching. Hard to tell from a distance what is causing the error. Looking at the error message, it seems like you have specified an xlsx file instead of a word document. Perhaps when you have initiated the word document?! doc = DocxTemplate(word_template_path)
If online data fetching in excel on 1 min interval of different set, eg Stock data Time open high low close 9.15 56 59. 56 57 N here i want visualization of time on X axis n open on Y axis in plot & same screen X axis time but close on Y axis in another plot I search subplot something Please make video on it...
How to get "NONREFUNDABLE" number in 2 decimal float number (ex.: 1.00)? When creating each word document to show 2 decimal float number in place of "NONREFUNDABLE".
I got where is the problem. In the column was string format and number format as well, and therefore was the error. Can I make an "if-else" solution, or how can i solve the problem, if in the column has string skip that row...
What do you mean by one output file? Should each word document be appended to each other? Please share some additional information and/or provide an example. Thanks!
Hi Sven, Would you please create a video on how to scrape a TH-cam video without the API? I would like to get the followings from a single TH-cam Video: Title Description Comments Once the above data is collected, it would export into a csv. Let me know if you have any follow up questions! Keep up the amazing work! Thank you! Qasim
Hi Qasim, Thanks for your video suggestion. In my opinion, using an API would be more reliable. Any particular reason you would like to build a web scraper from scratch instead of using the API?
@@MQKhilji Ok noted, but I cannot make any promises. You might want to check out the following video. It is very similar to your idea: Scrape a website and save the results to a CSV file: th-cam.com/video/ySNSY7iiBDY/w-d-xo.html I hope this helps!
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you! -Sven
Thank you for the great tutorial! I'd like to apply this way to substitute many placeholders in a template document. I was wondering if it is possible to read(or set) excel first column as header like: header↓ -------------------------------------------- NAME PersonA PersonB PersonC AMOUNT 123 456 789 LINE1 detailsA detailsB detailsC LINE2 ...A ...B ...C headerA headerB headerC . . .
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
*I will be here in the comments section. If you have any questions, please let me know.*
Quick note: At 06:42 min, the Word document's date is different compared to the Excel screenshot. Reason: I have edited the video a couple of days after the initial recording. When I took the screenshot from the Excel file, I did not adjust the 'today' formula. This is causing the 'difference'.
This makes sense! Thank you, Sven!
As always, you deliver. It's going to save a week for the accountants at my office, and error rate is going to go down drastically, thank you. :)
Thanks for the fantastic video idea :)
This was so much easier than every other "tutorial" I found out there. Thank you!
Happy to hear that it was useful; thank you for taking the time to leave a comment and for watching the video! 👍
You are the best, man. With your help I managed to solve a big problem in my company even knowing the basics of Python.
Happy to hear that it was useful; thank you for taking the time to leave a comment and for watching the video!
Hello there. I am from Uzbekistan. Thank you very much. Very helpful video. You saved me a lot of time. Good luck
Happy to hear that it was useful; thank you for taking the time to leave a comment and for watching the video! 👍
This video is awesome. Simple, straight forward and No BS'ing. Thanks a lot and keep up the good work :)
Thank you! Glad you liked the video!
How about combining multiple text files together into one, like a table of contents and heading sections all saved as separate files? Part of the goal is to avoid tracking down all the places a boilerplate has been used, versus changing a the boilerplate in a central file and having that update in every file that includes it. The other part is to have more granular version control and to make it easier to handle a document - to just hold a chapter at a time, rather than a whole book.
Cheers, thanks for your thoughts and your videos! Your channel is the most important and valuable to my work. I don't have users looking for me to code apps for them; I just have a ton of "office suite" tasks to achieve, with not enough time, and I hate the idea of wasted time and effort. Thanks again.
Interesting idea. Well noted, but I cannot make any promises.
Thanks for watching the videos & your comments/suggestions. I appreciate it!
I need a solution for multiple records for a single recipient. or a dynamic table in word document
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
This is GOLD! Thanks a ton buddy!
Glad it helped! Cheers, Sven ✌️
Awesome! Love your channel and work - thank you!
Thank you! :)
Hey, thanks for the great video it helped me alot! I have a question regarding strfime(). I want to have alterneting time formats for the same placeholder and want ask if thats possible. So lets say for the first row its (%y %m %d) then for the second row (%d %m %y) and then third row the same as first… would this be possible? Thanks for any help!
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you! -Sven
Beautiful. Just beautiful. Python rules for this kind of stuff!
Glad you liked it. Thanks for watching and taking the time to leave a comment! -Sven ✌️
Very useful video. Thank you. How can we transfer data from multiple Excel sheets to a Word file? Do you have a video? I would be very happy if you could help.
Thanks for watching. I don't have a video on that, but feel free to use my code as a starting point. Happy Coding! -Sven ✌️
This is amazing. Thank you so much. YOU are the best!!!!!!
It's very kind of you to say so, thank you! 👍😀
Very helpful,,, sir is it possible to save it on one docx file only, rather than create multiple msword files?
Thanks for watching. Yes, that is possible. Here you are: chatgpt.com/share/677a2ddc-010c-8001-a816-e68012a6a670
@CodingIsFun thank you sir.. hope you do it in your tutorial... more pyhton app sir.. thank you very much...
Woow! this is amasing
Thanks you for sharing.💯
Glad you liked it. Thanks for watching.
thank you bro
My pleasure! Appreciate you taking the time to watch and leave a comment.
Exactly what I needed! Thank you!!
Glad I could help! Thanks for watching! 👍
Awesome tutorial!
How to make a little tweak to final output, by changing date format from YYYY-MM-DD to DD.MM.YYYY.?
Thanks!
Please see below:
df["TODAY"] = pd.to_datetime(df["TODAY"]).dt.strftime('%d.%m.%Y')
df["TODAY_IN_ONE_WEEK"] = pd.to_datetime(df["TODAY_IN_ONE_WEEK"]).dt.strftime('%d.%m.%Y')
Great video, thanks! Can I make the same procedure for excel files? I need to populate excel template not a word one
Thanks for watching. Yes, that is absolutely possible. You might want to check out the xlwings package. That said, I cannot provide you an examples, as I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Great tutorial. Thank you very much.
As for the dates, I noticed the output in the word document is 11-02-2022 and this is different from the dates in the excel file. How can I fix that?
Good catch. I have edited the video a couple of days after the initial recording. When I took the screenshot from the Excel file, I did not adjust the 'today' formula. Hence, the date is not the same. I hope this clarifies.
@@CodingIsFun Thanks a lot. I didn't talk about the dates in the video. I already tested the code and got incorrect dates.
@@KhalilYasser The output is based on the Excel file. When I saved the Excel file, it was 2022/02/11.
Open the Excel file, check today's date and save the file. Afterwards, rerun the script.
Alternatively, use the DateTime module directly in the Python script, as shown in the video. I hope this helps!
Thank you very much. It seems I have to reopen the excel file to update the dates. Best Regards
Very interesting. I think I should start learning Python.
Glad you liked it! Happy Coding/Learning!
Very interesting material, thank you ❤
Glad you liked it. Thanks for watching! :)
Fantastic explanation. For example, however, users don't have the columns with "NAME, VENDOR, AMOUNT, NONREFUNDABLE....". They have columns with different names? How can we solve that? You can guide the way to code to adapt with variable names with column? Thanks a lot!
Thank you for watching. As outlined in the video, you would need to adjust the column headers (names) to suit your specific needs. Just make sure that the column header names match the placeholders in Word. I hope this information is helpful. Happy coding!
Can you suggest the way to allow users use any values in column names without correct the code?
Nice handy script. Would like to see include a table (with variable number of rows) in the word document.
Great suggestion!
absolutely amazing! Thank you, kindly.
My pleasure! Appreciate you taking the time to watch and leave a comment. 👍
Love your content. It’s very clear and well explained. I was hoping you can help me.
I need to create a table in the document, dynamically with hiding rows and columns based on if values exist in the excel data source. How can I modify this solution to create and add tables?
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
hi extremely helpful video but is there any way to insert a placeholder of an excel column that has both text and dates in word facing the issue of for dates it shows time as well which i dont want
Thanks! The following might help: www.extendoffice.com/documents/excel/3325-excel-concatenate-retain-formatting.html#:~:text=1.,2.
Thanks a lot for the video!
I have a quick question, how can I add a (strftime) to change the date format from yyyy-mm-dd to dd-mm-yyyy?
Thanks for watching.
Try out the following:
df["TODAY"] = pd.to_datetime(df["TODAY"]).dt.strftime('%d.%m.%Y')
df["TODAY_IN_ONE_WEEK"] = pd.to_datetime(df["TODAY_IN_ONE_WEEK"]).dt.strftime('%d.%m.%Y')
Great video. Congratulations.
Glad you liked it. Thanks for watching and taking the time to leave a comment! Cheers, Sven ✌️
Hello! I am getting an error 'pip' is not recognized as an internal or external command,
operable program or batch file.
Any idea how to fix it? and do you have any beginners videos?
Thanks for watching. Did you install Python?
Hi Sven, i was wondering if you could help me create multiple excel files, each containing details of different customers, using the same procedure as shown in this video. Same placeholder technique but for excel. Would be great help, Sven. Thanks
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
What interests me most at the moment is
1) creating the rubric of a contract for different parties who work together (party, address, executing department, PI, address of the department. The number of parties should be selectable. That means for example: 10 parties in the rubric. I need a GUI where I type in how many parties and give each party various attributes, like the one listed above.
2) creating 1 single page for the signature of 1 party - which consist of the PI and the head of the legal office / chief of (...). That means for example: 10 parties listed above as a head line, 10 signature pages for 20 people.
This process is really exhausting and should not be done manually. Maybe this is easier said than done.
Thanks in advance!
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
@@CodingIsFun No issue, mate. I by my side am a Legal Tech student and work 40/7. I understand how you feel. :-)
If I want to paste based on one column same records in 1 word file and based on another the same column the other records in another word file, how can we do that?
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
Hi, Excellent video. Is it possible to update a Word document with a picture of the tables from an Excel spreadsheet. The word documents will have bookmarks in various places for the tables. Thanks
Thank you! Yes, that is possible. Check out the following video: th-cam.com/video/T3meVMaV8AA/w-d-xo.html
Many thanks, Mr.Sven
You're very welcome! Thank you for watching and for the comment!
Thanks and awesome 🙂What are you doing with base_dir = Path(__file__) command? I get NameError: name '__file__' is not defined...
Thanks!
Are you using a Juypter Notebook? Try the following instead:
base_dir = Path(__file__).parent if "__file__" in locals() else Path.cwd()
I recommend watching the pathlib tutorial on my channel to understand the line. Happy Coding!
Great video! This allows me to pursue programmatic seo now (after I scrape my data)! I did have a problem with the __file___ for the directory path. It kept saying it wasn't defined, so I just omitted it from the code. I'm using Anaconda/Spyder Python 3.9 for coding if that helps solve it. Thanks!
Thanks for watching. Glad it was helpful. I have modified the base_dir path as follows ⤵
base_dir = Path(__file__).parent if "__file__" in locals() else Path.cwd()
github.com/Sven-Bo/word-generator-based-on-excel-list/commit/b6e38a0925547d0ce0374835d5d5b4d086df8508
Thanks for pointing it out!
How can we modify the output to dump all the data at the same document? I was thinking in change the output to the same file but that will overwrite each time. Any ideas? Thank you and great video!
Thanks for watching the video. After creating the documents, you could merge them: eazytutorial.com/index.php/2021/08/13/merge-word-docs-python/
Happy Coding!
@@CodingIsFun It worked, thank you !!
Hi sir. Is it possible to make GUI for this?
If yes, is it possible to choose different excel files everytime I want to generate the documents? For example, I want to use the same docs template, but the data will be from the different excel file each time.
Do you know how to make it work?
Thanks for watching the video. Yes, that is possible. Check out my PySimpleGUI tutorials on my channel. I hope it helps! Happy Coding!
Nice work! Is it possible to automate document generation incorporating different level bullets? My template has a table with a bullet and iterates over the inputs. Some are bullet level one, some go to bullet level 2. But it is all bullet level one when brought over to the template.
Thank you for watching the video and for your question. Unfortunately, I do not know how to implement that right off the bat. I would also need to search the internet for a solution. Sorry that I cannot help!
When it comes to use numbers in excel, how do I deal with the numbers formats? please I'd like to know
Have a look at the following blog to learn how to format numbers in Python: queirozf.com/entries/python-number-formatting-examples
I hope it helps! Happy Coding!
I was wandering here and there for a decent video but I came across your channel and it blew my mind. Thank you for the awesome videos you post. Is it possible to create a python script which will take inputs as form from us in GUI and then save them to excel and return the output in notepad and open the file?
Highly appreciated if I can get a response.
Happy to hear that you are enjoying the videos. Regarding your questions, you could use the following solution as a starting point: th-cam.com/video/svcv8uub0D0/w-d-xo.html
I hope it helps! Happy Coding!
Now that I write python code on the web online, is it possible to do something like this video without installing an IDE?
Ps: look at your proton orbiting electron icon file .py, are you using the Atom IDE? I plan to use the Pycharm IDE
Thanks for watching. You can use whatever text editor / IDE you want.
Also, in general you could run the code online, but I cannot explain the entire concept in a single comment. The best way would be to try it out yourself. In that way, you will also learn a lot of things along the way. Happy Coding!
Is that possible to change "doc = DocxTemplate(word_template_path)" that program use another Template if row contain NaN values?
I mean for that row where is "NaN" - use another 'DocxTemplate'
ex.:
creating 2 Template word file
use template2 just for that row (where has NaN value) to create word document
Yes, it is possible by inserting the respective if conditions. Yet, I am missing the time to code out an example for you. Thanks for your understanding!
Your videos are great!
It's very kind of you to say so, thank you!
Great video! :) Also, I'm looking into based on a specific field/values from the Excel sheet, how to modify/set the values of radio buttons (to Yes/No) in the Word document?
Thank you for watching the video and for your question. Unfortunately, I do not know how to implement that right off the bat. I would also need to search the internet for a solution. Sorry that I cannot help!
@@CodingIsFun Thanks for your quick response :) If you do find a way, please let me know. Thanks!
Is it possible to create an unknown amount of place holders?
Example i have a list of products, an then a list of all customers who purchased from lets say 2021. Is it possible to create a word doc to each customer containing all SKU's they bought from the list of products similar to your example but with multiple placeholders?
Thanks for watching. You might want to include a table which will be expanded dynamically based on the variables you provide.
Have a look at the following example:
Code: github.com/elapouya/python-docx-template/blob/master/tests/dynamic_table.py
WordTemplate: github.com/elapouya/python-docx-template/blob/master/tests/templates/dynamic_table_tpl.docx
I hope it helps! Happy Coding!
Love your content as always. At work, I'm tasked with creating many PDFs from an excel template. I'm thinking of looping through a script that uses xlwings to implement the placeholder values that I'll pull from a dataframe. Do you agree with this approach or know of a better solution? Any suggestions on which package to use to export to PDF would be super useful too!
Hey there! I'm glad you're enjoying the content. Sounds like you're trying to create PDFs from an Excel template using xlwings. That approach should work well for you, as xlwings is a good package for working with Excel files in Python. You can use the following method to export the workbook to a PDF: docs.xlwings.org/en/stable/api.html#xlwings.Sheet.to_pdf
I hope it helps. Happy Coding!
hi,
can I do the opposite from word to excel?
Thank you for watching the video and for your question. Unfortunately, I do not know how to implement that right off the bat. I would also need to search the internet for a solution. Sorry that I cannot help!
Hi This is awesome reduces lot of work. But how to add different images dynamically in word document
Thanks! I have explained how to insert images in the following video: th-cam.com/video/T3meVMaV8AA/w-d-xo.html
I hope this helps!
This is fantastic! My first Python Code! Thank you for this very useful tutorial.
Sven, please could I ask how do I change the format from YYYY-MM-DD to DD-MM-YYYY in your script? Thank you!
Thanks for watching.
Try out the following:
df["TODAY"] = pd.to_datetime(df["TODAY"]).dt.strftime('%d-%m-%Y')
df["TODAY_IN_ONE_WEEK"] = pd.to_datetime(df["TODAY_IN_ONE_WEEK"]).dt.strftime('%d-%m-%Y')
Thank you so much! Appreciate it!
I managed to automate my process and automate word docs to be populated with values from csv file, but sometimes with some word files i keep on getting an error when trying to open a word doc i get 'The file cannot be opened because there are problems with the contents'
Thanks for watching and for your question. Hard to tell from a distance why you are facing an error. Sorry that I cannot help.
@codingisfun
Dear Sven, have you ever done a project of creating a reference letter( zeugnis, zwischenzeugnis) using python or vba? I would love to see your variant of it. Normally an employer fills in a word template, which is then moved to an excel tool. At the end, in the tool you click Zeugniserstellung and the new doc gets generated.
I have not done exactly that kind of project, but similar ones. It is definitely possible with Python or VBA, but as with almost all coding projects, there is often no one-size-fits-all solution. So, you could take the code from the video as a starting point to create your own custom solution. Happy Coding!
when i change or add data to the excel sheet it's not reflecting in the word documents, what did i miss
Thanks for watching and for your question. Hard to tell from a distance. Sorry that I cannot help. Cheers, Sven ✌️
Can we pick particular columns from the excel and prepare word doc?
Thanks for watching the video. That is possible.
Option A: Keep all Excel columns and insert the placeholder you want (in word)
Option B: In pandas, you can also select specific columns. Have a look here: pandas.pydata.org/docs/getting_started/intro_tutorials/03_subset_data.html
I hope it helps!
@@CodingIsFun Thank you so much brother ❤️
Hey! In this Scenario we took particular excel for generating, but what if we want to take any excel and generate docs. We always cannot come and change the name of the excel in the code right. So could you please make a gui interface to pick the file from local files and generate docs?
I hope you'd help.
Thanks!
@@maneeshreddy7088 I do not have the time to code out an entire solution based on your needs. I hope you can understand that. That said, there are many Python modules available to develop a GUI. My favourite library is 'PySimpleGUI'. Perhaps the following video helps you to get started with PySimpleGUI:
th-cam.com/video/svcv8uub0D0/w-d-xo.html
Happy Coding!
Great as always. Is possible to add a table from a data frame or excel sheet? Can you do a video with powerpoint in future? For example reports for products or costumers on one sheet with two or three kpis per product or costumer. In my case I used groupby in pandas, get the sums and then must write this manually in powerpoint. And I have to add a logo as a png or jpg per product or customer.
Thank you, Mike!
Yes, you can also inject data from Excel into your Word template. You might want to check out the following video, where I have done something very similar: th-cam.com/video/T3meVMaV8AA/w-d-xo.html
Great video suggestion (PowerPoint automation)! I noted your idea, but I cannot make any promises. I hope you can understand. Thanks!
@@CodingIsFun Thank you for the answer.
Really nice script! Can't praise it enough
However.. Have you or anyone found a solution/stumbled upon the issue of images? Like if we want to apply images when rendering the documents. Ex. Link to image (preferably if possible, multiple images) in excel or similar?
Thanks for the kind words. You could also render images. Check out the following tutorial: th-cam.com/video/T3meVMaV8AA/w-d-xo.html
I hope it helps! Happy Coding!
Will be great the same tutorial but using PDFs instead, what do you think?
Thanks for the suggestion. Have a look at the following video/code. In one of my previous word automation videos, I have also included a function to save the output as a pdf file:
github.com/Sven-Bo/python-word-automation
I hope this helps!
@@CodingIsFun amazing!
Amazing ! thank you and GOD bless you for this sharing. but, please help me to turn it into an .exe file. I tried, everything seem to be ok, but the output folder is empty and i get error saying " no such file or directory". thank again and waiting for your feedback.
Thanks for watching. Please try to replace the following line:
❌base_dir = Path(__file__).parent if "__file__" in locals() else Path.cwd()
with this:
✔ base_dir = Path.cwd()
I hope it helps!
@@CodingIsFun Thank you a lot for your feedback. I've just tried, and now everything is ok. You are a blessed guy for me. You deserve more than 1M subscribers. I will share massively your channel to help you in this way. Thank again !
Love that. Thanks!
Glad to hear you liked it! Thank you for commenting and watching. 👍
@@CodingIsFun Just a couple of questions: how can I save the word files with both vendor and client name? Now it’s just a vendor name. Also, I wanted to save the file as PDF. When I changed the .docx to .PDF, the acrobat reader couldn’t open it.
@@ahv5457 Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
Please, how can I get all the reports in one word file?
Thanks for watching the video. After creating the documents, you could merge them: eazytutorial.com/index.php/2021/08/13/merge-word-docs-python/
Happy Coding!
Sir please help….
I want one doc file. By this code we are getting multiple files. Can you share any other/updated code for getting single document output. Please please sir repl
Sir, Please Provide the solution for one output file instead of multiple
What do you mean by one output file? Should each word document be appended to each other? Please share some additional information and/or provide an example. Thanks!
how I can do this with cpp please give me a resource for it.
Thanks so much for watching the video and leaving a comment! Your request is definitely noted. However, I get a ton of requests for custom solutions and, as much as I'd love to help everyone out, I just don't have the time in my schedule to develop and test all of them. I hope you can understand. Happy Coding!
One question : how to print all vendors contract in one click instead of word file creating?
After creating the Word documents, you can use the COM interface to open Word and print the document.
Have a look here:
darkcoding.net/software/printing-word-and-pdf-files-from-python/
@@CodingIsFun oh great 👍
I wonder is there a way to use this script as an external user. I would be a great cheat sheet for my team at work but I'm the only one using python.
Thanks for watching! You can use PyInstaller to create an executable file of your script, making it easy for your team to use without needing Python installed
@@CodingIsFun not sure how to do that. Maybe perfect tutorial for another video :D
@@MarianGushev th-cam.com/video/LzCfNanQ_9c/w-d-xo.html&feature=shares&t=1480
here you go
@@CodingIsFun wow you got my subscription sir. Amazing work and very useful for people working in corporate. :)
@@MarianGushev welcome aboard :)
how to filled the cells in excel without get new files?
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
Hello, how can I create these fields in the word document? {{}}
Thanks for watching. Simple type in a Word document "{{}}"
Hi, thank you for sharing. When i tried to replicate with a different table, I keep meeting this challenge. "ValueError: file 'input.xlsx' is not a Word file, content type is 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml' Not sure what is causing that. Thank you
Thanks for watching. Hard to tell from a distance what is causing the error. Looking at the error message, it seems like you have specified an xlsx file instead of a word document. Perhaps when you have initiated the word document?! doc = DocxTemplate(word_template_path)
@@CodingIsFun Oh yes.. it if fixed. Thank you:)
Can it be used in watermarks?
Yes, it also works with watermarks. I have just tested it out for you.
@@CodingIsFun appreciate it, this would actually solve a big problem I had.
If online data fetching in excel on 1 min interval of different set, eg
Stock data
Time open high low close
9.15 56 59. 56 57
N here i want visualization of time on X axis n open on Y axis in plot & same screen X axis time but close on Y axis in another plot
I search subplot something
Please make video on it...
Thanks for your suggestion!
Have you tried doing things like this in Google Colab?
I have not tested it on Google Colab, but feel free to do so :)
In the following case, will an error occur ? : the data column has more than 255 characters
Feel free to try it out. Thanks!
How to get "NONREFUNDABLE" number in 2 decimal float number (ex.: 1.00)?
When creating each word document to show 2 decimal float number in place of "NONREFUNDABLE".
Thanks for watching. Here you are: pastebin.com/TUQd110T
Wow, such a fast answear; appreciate that.
I will try it tomorrow. 🙏
I tried the solution, but an error occurred:
ValueError: Unknown format code 'f' for object of type 'str'
I got where is the problem.
In the column was string format and number format as well, and therefore was the error.
Can I make an "if-else" solution, or how can i solve the problem, if in the column has string skip that row...
@@totaumsahi If you want to use an f string (as in my solution), please use Python 3.6 or higher
Sir, Please Provide the solution for one output file instead of multiple
What do you mean by one output file? Should each word document be appended to each other? Please share some additional information and/or provide an example. Thanks!
Sir. Thank you for reply.
I wand append all word file to one word file.
@@navikaran1 After creating the documents, you could merge them: eazytutorial.com/index.php/2021/08/13/merge-word-docs-python/
Happy Coding!
@@CodingIsFun Hi, Intstead of each row having its own document. How do I get it to be on the one word document template?
Hi Sven,
Would you please create a video on how to scrape a TH-cam video without the API? I would like to get the followings from a single TH-cam Video:
Title
Description
Comments
Once the above data is collected, it would export into a csv. Let me know if you have any follow up questions! Keep up the amazing work!
Thank you!
Qasim
Hi Qasim,
Thanks for your video suggestion.
In my opinion, using an API would be more reliable.
Any particular reason you would like to build a web scraper from scratch instead of using the API?
@@CodingIsFun thank you for your prompt response! No particular reason, just wanted to learn. Thank you 🙏
@@MQKhilji Ok noted, but I cannot make any promises.
You might want to check out the following video. It is very similar to your idea: Scrape a website and save the results to a CSV file:
th-cam.com/video/ySNSY7iiBDY/w-d-xo.html
I hope this helps!
@@CodingIsFun Okay, no problem! I will check it out. Thank you!
Excelente !!!!!
Thanks! 👍
superb
Thank you! :)
I am a Korean student. What I want to ask is how to put multiple Excel data in one word file, not individual files.
Perhaps the following video might help you: th-cam.com/video/T3meVMaV8AA/w-d-xo.html
Happy Coding!
Please add to the tutorial by saving the document in pdf and sending it via WhatsApp
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you! -Sven
Ausom
Thanks!
Thank you for the great tutorial!
I'd like to apply this way to substitute many placeholders in a template document.
I was wondering if it is possible to read(or set) excel first column as header like:
header↓
--------------------------------------------
NAME PersonA PersonB PersonC
AMOUNT 123 456 789
LINE1 detailsA detailsB detailsC
LINE2 ...A ...B ...C
headerA
headerB
headerC
.
.
.
Thank you very much for watching the video and your comment. Your requirements are well noted. Yet, I receive many requests for creating individual solutions. As much as I want to help, I simply do not find the time in my daily schedule to develop & test all the different requests. I hope you can understand. Thank you!
@@CodingIsFun Thank you for your reply :)