I am creating a script that reformats a .txt file based on the special character each line starts with (i.e. line starting with & sends content to a formulas and definitions section and % generates a table).
Using python-docx, I initialize the document and pre-defined sections as such:
document = Document()
document.add_heading('Definitions and Formulas', level=1)
forms = document.add_paragraph()
Using the new paragraphs as an anchor point, above which the most recent line is added as a new paragraph with insert_paragraph_above.
After looking for ways to do this with a table (inserting above the anchor paragraph) I have generated with python-docx, I am coming up blank. Does anyone have a solution?
Many thanks in advance.
I tried creating a custom function using insert_paragraph_before, but did not work because tables are not paragraphs in python-docx