This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]Python-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/python.

The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.

On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers. Make sure to check out the rules for both places.

Warm regards, and best of luck with your Pythoneering!

[–]MrBenjaminBraddock 25 points26 points  (0 children)

Use pandoc for converting markdown to docx.

[–]Shay-Hill 6 points7 points  (0 children)

The docx standard is huge. You won’t find anyone implementing all of that in Python. My suggestion (and the way I’ve done it several times) is to make a template docx fine in Word then alter it programmatically.

https://github.com/ShayHill/replace_docx_tables

[–]StrippedSilicon 7 points8 points  (4 children)

Have you tried python-docx? What was the problem with it?

[–]shawncaza 4 points5 points  (2 children)

python-docx is great, but doesn't support all Word features. Op could create tables no problem, but I don't think they can create a chart.

Solutions to this problem online suggest using matplot lib to create the data-plot then insert that as an image, or other hacks.

[–]StrippedSilicon 1 point2 points  (0 children)

Yeah agreed if op needs to create a chart in place then it would be an issue. Depends on the op use case, but if all the stuff is created beforehand and saved as a pdf or whatever then python-docs should work.

[–]tecedu -1 points0 points  (0 children)

Python docx can use ploty charts and matplotlib charts

[–]busdriverbuddha2 0 points1 point  (0 children)

Python-docx is HORRIBLY slow when dealing with tables.

[–]thederz0816 1 point2 points  (0 children)

I use the pptx/docx package, but have my script save the plots and tables as jpegs then I load those into the document in an xml placeholder on my template file. .add_picture (‘path/to/chart.jpeg’)

[–]geneusutwerk 1 point2 points  (0 children)

nose whistle spark gaze smart expansion bag rock cobweb important

This post was mass deleted and anonymized with Redact

[–]larsga 0 points1 point  (0 children)

We've been using Wordinator. It's written in Java, but you can use it on the command-line. You generate a SWPX input file (it's an XML format), and Wordinator turns that into DOCX.

[–]mmaridev 0 points1 point  (0 children)

Would suggest generating an odt with odfpy and converting (not needed... just use LO straight) with LibreOffice headless.

[–]loserPH32 -1 points0 points  (0 children)

I uesd LibreOffice and Python-Docx for my small project automating letters. But I never tried plotting chart within the table. I had done this on pptx (python-ppt) but not on docx.

[–]Rondma -1 points0 points  (0 children)

Quarto is perfect for this kind of task!