Skip to content

Instantly share code, notes, and snippets.

@includeamin
Created March 15, 2019 21:25
Show Gist options
  • Save includeamin/1099860a4150485c9e0763c9f2611546 to your computer and use it in GitHub Desktop.
Save includeamin/1099860a4150485c9e0763c9f2611546 to your computer and use it in GitHub Desktop.
working with docx [python-docx]
from docx import Document
from datetime import datetime
months = ['Jänner','Februar','März','April','Mai','Juni','Juli','August','September'
,'Oktober','November','Dezember']
def main():
position = input("Position :")
website = input("WebSite :")
company = input("Company :")
now = datetime.now()
amin = Document(docx='Anschreiben.docx')
for paragraph in amin.paragraphs:
if 'XXXXX' in paragraph.text:
paragraph.text = 'Bewerbung auf Ihr Stellenangebot als {0} '.format(position)
if 'Sari' in paragraph.text:
paragraph.text = 'Sari, {0}. {1} {2}'.format(now.day,months[now.month],now.year)
if 'XsiteX' in paragraph.text:
paragraph.text = 'Da mich ihre Anzeige auf {0} sehr angesprochen hat und genau meine Vorstellungen über ' \
'meine zukünftige Arbeitsstelle entspricht, möchte ich mich hiermit für die angebotene ' \
'Stelle bewerben und reiche ebenfalls meinen Lebenslauf ein. '.format(website)
for table in amin.tables:
for row in table.rows:
for cell in row.cells:
for paragraph in cell.paragraphs:
if 'Unternehmen' in paragraph.text:
paragraph.text = company
if 'Ansprechpartner' in paragraph.text:
paragraph.text=''
if 'Adresse' in paragraph.text:
paragraph.text = ''
amin.save('aminjamal.docx')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment