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)
相关推荐
小灰灰搞电子23 分钟前
Python 信号量详解:并发控制实战
python·信号量
新时代牛马32 分钟前
cyclictest 毛刺从哪来?从ftrace、latencytop、perf到IRQ/调度延迟定位
android·开发语言·python·kotlin
Dxy12393102161 小时前
Python如何结合AI解决数据分析问题
人工智能·python·数据分析
IvanCodes1 小时前
Python 基础语法(七):推导式与常见遍历写法
开发语言·python
zhangzeyuaaa1 小时前
Python requests:raise_for_status() 与 4xx/5xx 异常层次详解
开发语言·python
泡海椒2 小时前
动态代理核心原理:JQuick-Java接口规则自动生成机制解析
java·开发语言·python
余槐i2 小时前
Firecrawl 实战:将网站转换为大模型可用数据
人工智能·python·工具·firecrawl
shirsl2 小时前
算法 Day 2 滑动窗口 + 栈 / 单调栈
开发语言·python·算法
步行cgn2 小时前
Spring 启动报错:BeanFactory not initialized 的原因与解决
java·python·spring
quantdash_cc2 小时前
股票历史数据为什么比实时行情更重要?回测结果失真的根源可能就在 K 线数据
开发语言·python·数据分析·量化交易·股票数据·quantdash