Python 官方文档:入门教程 => 点击学习
文章目录 前言一、pdfplumber库是什么?二、安装pdfplumber库三、查看pdfplumber库版本四、提取pdf中表格数据1.引入库2.定义pdf文件路径3.打开pdf文件4.获
pdfplumber是一个用于从PDF文档中提取文本和表格数据的Python库。它可以帮助用户轻松地从PDF文件中提取有用的信息,例如表格、文本、元数据等。pdfplumber库的特点包括:简单易用、速度快、支持多种PDF文件格式、支持从多个页面中提取数据等。pdfplumber库还提供了一些方便的方法来处理提取的数据,例如排序、过滤和格式化等。它是一个非常有用的工具,特别是在需要从大量PDF文件中提取数据时。
pip install pdfplumber
pip show pdfplumber
Name: pdfplumber
Version: 0.9.0
Summary: Plumb a PDF for detailed infORMation about each char, rectangle, and line.
Home-page: https://GitHub.com/jsvine/pdfplumber
Author: Jeremy Singer-Vine
Author-email: jsvine@gmail.com
License:
Requires: pdfminer.six, Pillow, Wand
Required-by:
import pdfplumber
local = '/Users/kkstar/Downloads/'
with pdfplumber.open(local+"demo_table.pdf") as pdf:
num_pages = len(pdf.pages)
for page_num in range(num_pages):
page = pdf.pages[page_num]
table = page.extract_table(table_settings={ "vertical_strategy": "lines", "horizontal_strategy": "lines", "intersection_x_tolerance": 15, "intersection_y_tolerance": 15 })
for row in table: print(row)
[‘username’, ‘nickname’, ‘article’]
[‘weixin_38093452’, ‘空空 star’, ‘130889268’]
[‘weixin_38093452’, ‘空空 star’, ‘130852811’]
[‘weixin_38093452’, ‘空空 star’, ‘130815851’]
Process finished with exit code 0
来源地址:https://blog.csdn.net/weixin_38093452/article/details/130915632
--结束END--
本文标题: 通过Python的pdfplumber库提取pdf中表格数据
本文链接: https://www.lsjlt.com/news/395856.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0