+ 3
converting files in python
hello fellow programmers. I have a problem with my project and I can't seem to find the answer online. I have a program that lets the user load a file, which is then inserted into a 2D array. The problem is, that for now it only works with the ".txt" documents. I've just recently found out how to insert ".docx" files using the "import docx2txt" library, but I still have to be able to insert ".doc", ".odt", ".rtf" files. I just need the plain text from those. I would really appreciate the help. Edit: ".odt" works (I used the "textract import") Edit2: ".rtf" works (I used with open methon) Edit3: I don't want to edit the file. I want to take its content and insert it into a 2d array using python
1 Antwort
- 1
Hello, Kruszyn!
Try this code:
file = open("document.doc", "w", encoding = "utf-8")
file.write("This is a file")
file.close()