1 year ago

#131967

test-img

dkk

how to extract the titles of a document .odt in Libreoffice - Python

I have a document in the .odt file,

I just want to extract the titles of this document :

in other words , I want to extract the "sentenses " or in others words "the "line" which are in bold in this documentdocument.odt :

my code :

from odf.opendocument import load
from odf import text
from odf import teletype
doc = load('result.odt')

for paragraph in doc.getElementsByType(text.Span):
    print (paragraph.getAttribute('stylename'))
    print(paragraph)

the document is in attached file :

Thank you for your help !

Regards,

python

libreoffice

odf

odfpy

0 Answers

Your Answer

Accepted video resources