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)
相关推荐
飞猪~3 小时前
LangChain python 版本 第一集
开发语言·python·langchain
2601_956319883 小时前
最新AI量化提效,先做可验证的小流程
人工智能·python
开飞机的舒克_5 小时前
FastAPI 实战入门:从路由、参数校验到依赖注入的后端开发指南
python·fastapi
霸道流氓气质5 小时前
Kiro 中反编译 JAR 包并分析字节码的流程指南
chrome·python·jar
人工智能时代 准备好了吗5 小时前
AI回答内容进入率监测:引用识别、文本匹配与语义判断
开发语言·人工智能·python
Metaphor6926 小时前
使用 Python 冻结 Excel 文件中的行、列和单元格
开发语言·python·excel
言乐66 小时前
Python实现建造微服务商城后台
开发语言·python·算法·微服务·架构
fenglllle7 小时前
chromadb emmbedding 向量检索
人工智能·python·embedding
cui_ruicheng7 小时前
Python从入门到实战(六):非序列容器
开发语言·python
百里香酚兰7 小时前
【python学习笔记】pyttsx3库疑似只播报一次语音
笔记·python·学习