[Python] python-docx 1.1.2 reads lines in file in reversed order

Discussão em 'Python' iniciado por Stack, Maio 2, 2025.

  1. Stack

    Stack Membro Participativo

    I was parsing through resumes and converting them into txt and came across very interesting problem. Some resumes were parsed in reversed order while others were normal. Example for 1 file:

    from docx.table import Table
    from docx.text.paragraph import Paragraph
    from docx import Document


    def iter_block_items(parent):
    for child in parent.element.body.iterchildren():
    if child.tag.endswith('}p'): # paragraph
    yield Paragraph(child, parent)
    elif child.tag.endswith('}tbl'): # table
    yield Table(child, parent)


    doc = Document("tests/CV test/EMP0015 Resume.docx")
    text = []
    for block in iter_block_items(doc):
    print(block.text)


    And when done text looks like this: [​IMG] While docx file looks like this: [​IMG] Has anyone came across similar problem?

    I tried different parameters but it didn`t help

    Continue reading...

Compartilhe esta Página