Python代码优雅解析PDF文件

主要功能:利用Python扩展库pdfplumber解析中文核心期刊要目总览.pdf文件成excel文件

解析文件:中文核心期刊要目总览.pdf

官方文档:pdfplumber · PyPI

具体代码:

python 复制代码
import pdfplumber
import pandas as pd

with pdfplumber.open("hexin.pdf") as pdf:
    print(len(pdf.pages))
    first = pdf.pages[0]
    ftable = first.extract_table()
    tables = ftable[2:]
    for page in pdf.pages[1:]:
        tables += page.extract_table()
    data_frame = pd.DataFrame(tables, columns=ftable[1])
    with pd.ExcelWriter('hexin.xlsx') as excel:
        data_frame.to_excel(excel, index=False)
相关推荐
RSABLOCKCHAIN6 小时前
AI Agents in LangGraph-2
人工智能·python
WA内核拾荒者7 小时前
WhatsApp 账号异常检测的自动化告警系统设计
数据库·python·自动化
码流怪侠8 小时前
【GitHub】Bend:让 GPU 并行编程像写 Python 一样简单
python·github
2401_894915539 小时前
GEO 搜索优化完整源码从零部署:环境配置、集群搭建全流程
开发语言·python·tcp/ip·算法·unity
zhiSiBuYu051710 小时前
Python3 模块开发与应用实战指南
python
databook11 小时前
用方差阈值过滤掉“惰性特征”
python·机器学习·scikit-learn
Freak嵌入式11 小时前
MCU 低功耗模式解析:时钟门控、电源门控、深度休眠
人工智能·python·单片机·嵌入式硬件·开源·依赖倒置原则·micropython
weixin_BYSJ198712 小时前
springboot校园自习室管理小程序---附源码32142
java·javascript·spring boot·python·django·flask·php
用户83562907805113 小时前
使用 Python 在 PDF 中绘制线条、矩形和自定义图形
后端·python