I have been trying to read a .docx file and copy its text to a .txt file
I started off by writing this piece of script for achieving the above results.
if extension == 'docx' :
document = Document(filepath)
for para in document.paragraphs:
with open("C:/Users/prasu/Desktop/PySumm-resource/CodeSamples/output.txt","w") as file:
file.writelines(para.text)
The error occurred is as follows :
Traceback (most recent call last):
File "input_script.py", line 27, in <module>
file.writelines(para.text)
File "C:\Python\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2265' in
position 0: character maps to <undefined>
I tried printing "para.text" with the help of print(), it works. Now, I want to write "para.text" to a .txt file.