I am new to python and i am trying to append new data to existing docx file using Python.
from docx import Document # for Word document
document = Document()
document.add_paragraph('My first paragraph')
document.add_paragraph("Second paragraph")
document.add_paragraph("Third paragraph")
document.add_paragraph("fourth paragraph")
document.add_paragraph("fifth paragraph")
document.save("testDocmod.docx")
document = Document('testDocmod.docx')
paragraphs = document.paragraphs
incr=1
for paragraph in paragraphs:
runs = paragraph.runs
for run in runs:
if(incr == 2):
run.text = 'Updatd text'
print run.text
incr = incr + 1
But its just updating the second element while i need to append it before second element