I am converting pdfs to text and got this code off a previous post:
Extracting text from a PDF file using PDFMiner in python?
When I print(text) it has done exactly what I want, but then I need to save this to a text file, which is when I get the above error.
The code follows exactly the first answer on the linked question. Then I:
text = convert_pdf_to_txt("GMCA ECON.pdf")
file = open('GMCAECON.txt', 'w', 'utf-8')
file.write(text)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-ebc6b7708d93> in <module>
----> 1 file = open('GMCAECON.txt', 'w', 'utf-8')
2 file.write(text)
TypeError: an integer is required (got type str)
I'm afraid it's probably something really simple but I can't figure it out. I want it to write the text to a text file with the same name, which I can then do further analysis on. Thanks.