[英]Extract specific Data values from Invoices PDF using PDFminer : Python
希望從具有不同結構的多個 PDF 中僅提取特定數據,
我已將所有 pdf 存儲到發票文件夾中。 我嘗試使用 pdfminer 庫從 pdf 中提取數據。
def extract_text(pdf_path):
text21 = ''
for page in extract_text_by_page(pdf_path):
text21 = text21 + str(page[:-1]) + ' '
return text21
inv = glob.glob(path+"/Invoice/*.pdf")
for i in inv:
print(i)
page = extract_text(i)
print(page)
data1 = str(page)
lan = len(data1)
x = re.search("Invoice Number:", page)
x1 = re.search("Invoice No:", page)
x2 = re.search("Bill No:" , page)
x3 = re.search("Bill:" , page)
if (x or x1 or x2 or x3):
if x:
yo = x.end()
elif x1:
yo = x1.end()
elif x2:
yo = x2.end()
elif x3:
yo = x3.end()
同樣查看 append 發票日期,發票 PDF 文件中的總賬單金額。 我如何 append 將所有值轉換為單獨的變量作為提取值以供其他進程使用。
使用pText
with open("input.pdf", "rb") as pdf_file_handle:
l = RegularExpressionTextExtraction("Invoice Number :[0-9]+")
doc = PDF.loads(pdf_file_handle, [l])
# do something with these events
l.get_matched_text_render_info_events_per_page(0)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.