What I am trying to do here is convert a pdf to a text file. This txt is not a pre-existing one, but it is created with creaty
. The problem is that although writy.write()
has worked fine in other scripts, it won't do anything to change the writy
file now, so it remains blank. What should I change?
thanks
p.s. the encoding in both open
exists because there is u\u0152 within the result
import PyPDF2
pdfFileObj = open('Computer_science_paper_1__HL.pdf', 'rb')
creaty = open('Computer_science_paper_1__HL.txt', 'w+', encoding="utf-8")
writy = open('Computer_science_paper_1__HL.txt', 'a', encoding="utf-8")
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
for x in range(1,pdfReader.numPages):
pageObj = pdfReader.getPage(x)
result = pageObj.extractText()
writy.write(result)