Я пытаюсь написать скрипт для считывания имен сертификатов, которые я сканирую, в мой входной файл.
from PIL import Image
import pytesseract
import sys
from pdf2image import convert_from_path
import os
# Path to Input
inputfiles = os.listdir('/home/morningdew72/Documents/Python/Input')
# Convert PDF to Image
for certificate in inputfiles:
PDF_file = certificate
certificate_image = convert_from_path(PDF_file)
# Create Output Text File
outfile = "outpage.txt"
# Convert Image to Text
f = open(outfile, "w")
text = str(((pytesseract.image_to_string(Image.open(certificate_image)))))
text = text.replace('-\n', '')
f.write(text)
f.close()
Я не могу преодолеть эту ошибку:
Traceback (most recent call last):
File "/home/morningdew72/anaconda3/lib/python3.7/site-packages/pdf2image/pdf2image.py", line 425, in pdfinfo_from_path
raise ValueError
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "pdftotextapp.py", line 13, in <module>
certificate_image = convert_from_path(PDF_file)
File "/home/morningdew72/anaconda3/lib/python3.7/site-packages/pdf2image/pdf2image.py", line 89, in convert_from_path
page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)["Pages"]
File "/home/morningdew72/anaconda3/lib/python3.7/site-packages/pdf2image/pdf2image.py", line 435, in pdfinfo_from_path
"Unable to get page count.\n%s" % err.decode("utf8", "ignore")
pdf2image.exceptions.PDFPageCountError: Unable to get page count.
I/O Error: Couldn't open file 'testpdf2.pdf': No such file or directory.
Моя конечная цель - уметь анализировать текст, сгенерированный выходным файлом, и сопоставлять имена сотрудников с их файлами компетенций. Чего мне не хватает на этом этапе? Спасибо.