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)
相关推荐
爱睡懒觉的焦糖玛奇朵1 天前
【从视频到数据集:焦糖玛奇朵的魔法工具使用说明】
人工智能·python·深度学习·学习·算法·yolo·音视频
yangshicong1 天前
第11章:结构化输出与数据提取 —— 让 AI 直接返回你想要的数据格式
数据库·人工智能·redis·python·langchain·ai编程
言之。1 天前
【Python】免费的中文 AI 配音方案
开发语言·人工智能·python
Warson_L1 天前
python dict key详解
python
天天进步20151 天前
Python全栈项目:从零手操一个高性能 API 网关
开发语言·python
安生生申1 天前
使用pygame实现2048
开发语言·python·pygame
徐图图不糊涂1 天前
搭建简易版的Rag系统
python·pycharm
灰灰勇闯IT1 天前
pyasc:用 Python 调用 CANN 的推理能力
开发语言·python
明月_清风1 天前
FastAPI 从入门到实战:3 分钟构建高性能异步 API
后端·python·fastapi
bellus-1 天前
ubuntu26测试win10的ollama大模型性能
python