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)
相关推荐
金銀銅鐵16 分钟前
用 Tkinter 实现简单的猜数字游戏
后端·python
copyer_xyf33 分钟前
Python 模块与包的导入导出
前端·后端·python
ice8130331811 小时前
【Python】Matplotlib折线图绘制
开发语言·python·matplotlib
copyer_xyf1 小时前
Python venv 虚拟环境
前端·后端·python
林爷万福2 小时前
GitHub 开源光谱数据处理项目推荐
python·光纤光谱仪
copyer_xyf2 小时前
Python 如何同时做很多事:进程、线程、协程
前端·后端·python
Full Stack Developme3 小时前
Spring Bean 依赖注入
python·spring·log4j
yuhuofei20213 小时前
【Python入门】Python中的元组tuple
python
清水白石0083 小时前
从菱形继承到 `super()`:彻底理解 Python MRO 与多继承方法查找机制
开发语言·python
百事牛科技3 小时前
两种方法锁定 PDF,拒绝内容被随意篡改
windows·pdf