[Chennaipy] To extract text from docx file using python

Thirunarayanan Srinivasan tstnarayan at gmail.com
Sun Jun 26 23:20:01 EDT 2022


Looks like your installation didn’t go through properly. If you are Python3
, can you try this.

pip uninstall python-docx
pip3 install python-docx


On Mon, 27 Jun 2022 at 8:45 AM vishnu prabha b v <vishnuprabhabv97 at gmail.com>
wrote:

> from docx import document
> document = Document('sample.docx')
> type(document)
> document.paragraphs
> type(document.paragraphs)
> document.paragraphs(0)
> document.paragraphs[0].text
> document.paragraphs[1].text
> index = 0
> for para in document.paragraphs:
>     index+=1
>     if (len(para.text)>0):
>        print("\n paragraph",index,"is")
>        print(para.text)
>
>
>
> In this ,I have used pip install python-docx
> even after installed , i have found No module found error.
> [image: image.png]
> help me to fix this problem and is this is the correct way to extract txt
> from docs?
> _______________________________________________
> Chennaipy mailing list
> Chennaipy at python.org
> https://mail.python.org/mailman/listinfo/chennaipy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/chennaipy/attachments/20220627/ad012b44/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 51359 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/chennaipy/attachments/20220627/ad012b44/attachment-0001.png>


More information about the Chennaipy mailing list