我想在python3中使用camelot从pdf中提取所有的表格。
import camelot
# PDF file to extract tables from
file = "./pdf_file/ooo.pdf"
tables = camelot.read_pdf(file)
# number of tables extracted
print("Total tables extracted:", tables.n)
# print the first table as Pandas DataFrame
print(tables[0].df)
# exp
我有一个PDF,其中包含表格,文字和一些图像。我想从PDF文件中的任何位置提取表格。
现在正在手动从页面中查找表。从那里,我将捕获该页面并保存到另一个PDF中。
import PyPDF2
PDFfilename = "Sammamish.pdf" #filename of your PDF/directory where your PDF is stored
pfr = PyPDF2.PdfFileReader(open(PDFfilename, "rb")) #PdfFileReader object
pg4 = pfr.getPage(126) #e
我正在寻找一个从PDF文件中提取文本和表格的解决方案。虽然有些包适合提取文本,但它们不足以提取表。
一种解决方案是使用Azure表单识别器布局模型,但是当我们有文本和表的混合时,它就失败了,特别是当表是某种文本格式并且它们将表和文本的内容混合在一起时(请参见Azure Form Recognizer代码)。
我也尝试过pypdf2和pdfplumber;下面是pypdf2的代码:
导入PyPDF2 data_path =“os.listdir/to/pdf/files”text = [] for fp in os.listdir(data_path):pdfFileObj =