0

I am trying to make docs read in python and I am not getting any error, but it also doesn't show what is written in document.

from docx import Document

import os


file = open('C:\\Users\\hamza\\Desktop\\Python\\qwe.docx','r', encoding='utf8' )

document =(file.read())
file.close()
some_programmer
  • 3,268
  • 4
  • 24
  • 59
Hamza
  • 3
  • 3
  • Refer this - https://stackoverflow.com/questions/36001482/read-doc-file-with-python – Mayank Soni May 25 '20 at 19:03
  • 1
    Does this answer your question? [Read .doc file with python](https://stackoverflow.com/questions/36001482/read-doc-file-with-python) – Andy K May 25 '20 at 19:09

1 Answers1

1

Try pip install docx2txt

from docx2txt import process
import os
path = r'C:\Users\hamza\Desktop\Python\qwe.docx'
text = process(path)

with open(os.path.basename(path) + '.txt', 'w') as f:
    f.write(text)