这是通过文件夹名称调用文件并提取数据的程序。现在我想将数据与我在下面程序中使用的关键字进行比较。但它给了我:
pdfReader = pdfFileObj.loadPage(0)
AttributeError: '_io.BufferedReader' object has no attribute 'loadPage'
我想删除错误并将关键字与提取的数据进行比较。我在这个程序中使用了 PyMuPDF 库。
import fitz
import os
pdfFiles = []
for filename in os.listdir('resume/'):
if filename.endswith('.pdf'):
print(filename)
# pdfFiles.append(filename)
os.chdir('C:/Users/M. Abrar Hussain/Desktop/cv/resume')
print('Current working dir : %s' % os.getcwd())
pdfFileObj = open(filename, 'rb')
pdfReader = pdfFileObj.loadPage(0)
with fitz.open(pdfFileObj) as doc:
text = ""
for page in doc:
text += page.getText()
print(text)
# split the docs
pageObj = pdfReader.getpage(0)
t1 = (pageObj.getText())
t1 = t1.split(",")
search_keywords = ['python', 'Laravel', 'Java']
for sentence in t1:
lst = []
for word in search_keywords:
if word in search_keywords:
list.append(word)
print('{0} key word(s) in sentence: {1}'.format(len(lst), ', '.join(lst)))
pdfFileObj.close()