作者:mobiledu2402852357 | 来源:互联网 | 2023-10-11 12:52
我正尝试从e-pdf中提取表格文本,并搜索相关名称(相近)应视为相同并填充值。
import tabula
#from tabula import wrapper
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
#from pdfminer.pdfpage import PDFPage
from pdfminer.pdfinterp import resolve1
file = open('filename','rb')
file_path = 'filename'
parser = PDFParser(file)
document = PDFDocument(parser)
# This will give you the count of pages
num = resolve1(document.catalog['Pages'])['Count']
df1 = tabula.read_pdf(file_path,pages=num,stream =True)
#Write the ouput in excel format
df1.to_excel("myoutput1.xlsx",sheet_name='Mainsheet'