当前位置:网站首页>One click extraction of tables in PDF
One click extraction of tables in PDF
2022-07-06 11:07:00 【zkkkkkkkkkkkkk】
Preface :
Due to work needs , Now we need to pdf The table in is not sealed properly csv Or database tables , Then it opened the road of forced research . Through investigation and research , At present, support from Editable pdf Read out the table Python Library has :pdfminer3k、tabula、pdfplumber etc. . All three libraries have flaws . But I'm still more inclined to pdfplumber . Self perception pdfplumber Simple and easy to implement functions . The following article is about pdfplumber Introduction to . For the other two Python If you are interested, you can check the relevant information by yourself . about pdf Editable in Central Africa ( Table recognition in the picture ) problem , Maybe this library can't help you .
Catalog
1.2、 Open source code git Address
One 、pdfplumber Introduce
1.1、 Introduce
Let's first look at an official introduction :pdfplumber Support vertical view PDF, View each text character 、 Rectangle and row details . Additional features : Table extraction and visual debugging . Most suitable for machine generated , Not scanned pdf file . On the whole pdfplumber It is a multi-function pdf Processing tools .
1.2、 Open source code git Address
1.3、 Official documents
1.4、 Installation mode
pip install pdfplumberTwo 、 Easy to use
2.1、 Data set introduction
Data is transaction flow ,pdf The table is editable . The purpose is to extract the data in the table .
2.2、 Code implementation
import pdfplumber
# path = 'D:\\202104147187110045_1.pdf'
path = '../recognize_img/demo_img/ A framed table can be edited .pdf'
pdf = pdfplumber.open(path)
# obtain pdf Page number object
print(pdf.pages) # [<Page:1>]
count = 0
for page in pdf.pages:
count += 1
# page.extract_text() You can grab all the information of the current page , Because there is a lot of content, please comment first .
# print(page.extract_text())
for table in page.extract_tables():
for row in table:
print(row)
print(f'============ The first {count} End of page parsing ============')
# To dataframe Output
# pass
pdf.close()3.3、 Results output
The result is output as a list per row . If necessary csv Or database requirements , You can first convert the following data into dataframe, Then output to the target source .
边栏推荐
- SSM integrated notes easy to understand version
- Postman environment variable settings
- 【博主推荐】C#MVC列表实现增删改查导入导出曲线功能(附源码)
- Install mongdb tutorial and redis tutorial under Windows
- [recommended by bloggers] asp Net WebService background data API JSON (with source code)
- Timestamp with implicit default value is deprecated error in MySQL 5.6
- MySQL 20 MySQL data directory
- JDBC principle
- Solve the problem that XML, YML and properties file configurations cannot be scanned
- Ansible实战系列三 _ task常用命令
猜你喜欢

QT creator shape

CSDN question and answer module Title Recommendation task (II) -- effect optimization

CSDN-NLP:基于技能树和弱监督学习的博文难度等级分类 (一)

A trip to Macao - > see the world from a non line city to Macao

【博主推荐】C#生成好看的二维码(附源码)

csdn-Markdown编辑器

CSDN question and answer tag skill tree (I) -- Construction of basic framework

图像识别问题 — pytesseract.TesseractNotFoundError: tesseract is not installed or it‘s not in your path

API learning of OpenGL (2003) gl_ TEXTURE_ WRAP_ S GL_ TEXTURE_ WRAP_ T

Neo4j installation tutorial
随机推荐
Navicat 導出錶生成PDM文件
安装numpy问题总结
Neo4j installation tutorial
引入了junit为什么还是用不了@Test注解
Timestamp with implicit default value is deprecated error in MySQL 5.6
Yum prompt another app is currently holding the yum lock; waiting for it to exit...
Windows cannot start the MySQL service (located on the local computer) error 1067 the process terminated unexpectedly
JDBC原理
MySQL19-Linux下MySQL的安装与使用
A trip to Macao - > see the world from a non line city to Macao
JDBC principle
[BMZCTF-pwn] 12-csaw-ctf-2016-quals hungman
Valentine's Day is coming, are you still worried about eating dog food? Teach you to make a confession wall hand in hand. Express your love to the person you want
Did you forget to register or load this tag 报错解决方法
QT creator design user interface
Esp8266 at+cipstart= "", "", 8080 error closed ultimate solution
报错解决 —— io.UnsupportedOperation: can‘t do nonzero end-relative seeks
[recommended by bloggers] background management system of SSM framework (with source code)
Breadth first search rotten orange
[download app for free]ineukernel OCR image data recognition and acquisition principle and product application