Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read .odt using python? [closed]

Tags:

python

pandas

I tried to read .odt using python with "odfpy" library, but it still doesn't work. Could you suggest me how to read .odt file using python or give me a simple source code.

Thank you

like image 644
Music Avatar asked Jan 02 '23 05:01

Music


1 Answers

First install odfpy library then,

In [21]: from odf import text, teletype
    ...: from odf.opendocument import load
    ...: 
    ...: textdoc = load("your.odt")
    ...: allparas = textdoc.getElementsByType(text.P)
    ...: teletype.extractText(allparas[0])
    ...: 
Out[21]: 'Hello World!'
like image 144
Nidhin Sajeev Avatar answered Jan 05 '23 16:01

Nidhin Sajeev