问题描述
我能够成功地从 pdf 中提取表格数据。
但是,我想从提取的数据中搜索关键字,例如:8.0,如果找到则认为测试通过。
for file in glob.glob(dir + "batch*.pdf"):
# print(file)
if file.endswith('.pdf'):
f=(open(file,"rb"))
pdf = PyPDF4.PdfFileReader(f)
count = 0
count = pdf.numPages
print("No.Of Pages:",count)
while count >= 0:
df = tabula.read_pdf(
file,stream=True,guess=False,pages="all",multiple_tables=True
)
# df.head(11)
print(df)
break
search_keywords=[ ‘Year','8.0']
for sentence in df:
lst = []
for word in search_keywords:
if word in sentence:
lst.append(word)
print('{0} key word(s) in sentence: {1}'.format(len(lst),','.join(lst)))
f.close()
else:
print("not in format")
我怎样才能达到上述目的
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)