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)
相关推荐
2301_807583237 分钟前
了解python,并编写第一个程序,常见的bug
linux·python
小白学大数据9 分钟前
构建混合爬虫:何时使用Requests,何时切换至Selenium处理请求头?
爬虫·python·selenium·测试工具
2401_8275602014 分钟前
【Python脚本系列】PyAudio+librosa+dtw库录制、识别音频并实现点击(四)
python·语音识别
BBB努力学习程序设计32 分钟前
Python自动化脚本:告别重复劳动
python·pycharm
BBB努力学习程序设计39 分钟前
Python函数式编程:优雅的代码艺术
python·pycharm
2501_940943911 小时前
体系课\ Python Web全栈工程师
开发语言·前端·python
田姐姐tmner1 小时前
Python切片
开发语言·python
t***31652 小时前
爬虫学习案例3
爬虫·python·学习
AI小云2 小时前
【数据操作与可视化】Pandas数据处理-其他操作
python·pandas
大佬,救命!!!2 小时前
更换适配python版本直接进行机器学习深度学习等相关环境配置(非仿真环境)
人工智能·python·深度学习·机器学习·学习笔记·详细配置