Python coding for turkish characters

I need to read pdf books, which are Turkish stories. I found a library called pyPdf. My test function, which is given below, is incorrectly encoded. I think I need to have a Turkish codec pack. Am I mistaken? if I am wrong, how can I solve this problem, how can I find this Turkish codec pack?

from StringIO import StringIO import pyPdf,os def getPDFContent(path): content = "" num_pages = 10 p = file(path, "rb") pdf = pyPdf.PdfFileReader(p) for i in range(0, num_pages): content += pdf.getPage(i).extractText() + "\n" content = " ".join(content.replace(u"\xa0", " ").strip().split()) return content if __name__ == '__main__': pdfContent = StringIO(getPDFContent(os.path.abspath("adiaylin-aysekulin.pdf")).encode("utf-8", "ignore")) for line in pdfContent: print line.strip() input("Press Enter to continue...") 
+4
source share
1 answer

What error / unexpected conclusion do you get specifically?

According to the pyPdf home page , pyPdf is no longer supported. But there is a fork called PyPDF2 ( GitHub ) to promises to handle a wider range of input PDF instances.

Perhaps upgrading to PyPDF2 solves your problem, I suggest you try it first.

+1
source

Source: https://habr.com/ru/post/1482208/


All Articles