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)
相关推荐
SEO_juper8 小时前
Node.js 重定向链检测工具:301 跳了几跳、有没有成环,一次看清
xml·开发语言·python·node.js·json·bash
曲径海盗8 小时前
【Python 学习第 37 天】for 循环
python·学习笔记·编程入门
心静财富之门9 小时前
Python 数据共享四种方案完整实例(同进程 / JSON / Redis / HTTP)
数据库·python·oracle
王仔小奶9 小时前
慢SQL治理与性能调优:DBA如何用Shell/Python提升运维效率?
python·sql·dba
用户0332126663679 小时前
使用 Python 快速在 PowerPoint 中生成表格【教程】
python
夜晚回家9 小时前
Python 身份运算符详解 | is 与 == 到底差在哪
python
fengye2071619 小时前
cpython框架结构
python
用户912940468484210 小时前
大模型返回 JSON 后,先过这道 Python 校验
python
Dmz丶10 小时前
前端转 AI 100 天 Day 32:LLM 客户端工程化——重试、超时、降级、限流
python
曲径海盗10 小时前
【Python 学习第 39 天】for 循环
python·学习笔记·编程入门