当前位置:网站首页>【代码学习】批量提取论文(pdf)的第一页
【代码学习】批量提取论文(pdf)的第一页
2022-06-09 11:50:00 【反科研pua所所长】
使用场景
软件学报论文录用的收尾工作中,需要提交所有参考文献首页的电子版压缩包(以文献序号作为文件名),也就是说,我一篇综述论文90+篇文献,需要逐一找到这些文献的pdf原版(现存电脑中的已经被我批注过了),然后逐一提取出pdf的第一页,这两件事情中,第一件事情较为复杂(因为所需论文的发表期刊/会议需要与引用一致),而第二件更简单且更耗时,所以付诸于程序
python批量提取pdf的第一页
from PyPDF2 import PdfFileReader, PdfFileWriter
import os
def pdf_split_3(pdf_dir, output_dir, begin_idx, end_idx):
for i in range(begin_idx, end_idx+1): # 所有要遍历的pdf文件
pdf_input = os.path.join(pdf_dir, '{}.pdf'.format(i))
pdf_output = os.path.join(output_dir, '{}.pdf'.format(i))
with open(pdf_input, 'rb') as open_pdf:
pdf_reader = PdfFileReader(open_pdf)
pdf_writer = PdfFileWriter()
pdf_writer.addPage(pdf_reader.getPage(0))
with open(pdf_output, 'ab') as out:
pdf_writer.write(out)
if __name__ == '__main__':
pdf_dir = '/data4/wangyan/pdf' # 所有pdf文件所在目录,默认其中的文件按照begin_idx到end_idx命名的,如1.pdf
output_dir = '/data4/wangyan/pdf_firstpage' # 所有pdf第一页的计划输出目录
begin_idx = 1 # 第一篇文献序号
end_idx = 92 # 最后一篇文献序号
pdf_split_3(pdf_dir, output_dir, begin_idx, end_idx)
边栏推荐
- IPO,联结一切的桥梁
- MySQL optimistic lock, pessimistic lock and multi granularity lock
- 爱可可AI前沿推介(6.9)
- 什么是硬实时数据库系统?
- lombok -异常 non-static variable org cannot be referenced from a static context
- Resttemplate usage details and pit stepping records
- 『忘了再学』Shell基础 — 28、AWK中条件表达式说明
- Excel | App_ Error in workbookactive cannot set the installed property of class addin
- Redis数据结构与介绍
- 从2022年的这几篇论文看推荐系统序列建模的趋势
猜你喜欢

08 | middle stage landing step 3: middle stage planning and design

聊聊技术和任务的重要性

.NET基础知识快速通关7

What are the deadlock troubleshooting tools?

9. lt.491 Longest increasing subsequence

. Net basic knowledge quick pass 8

柴云鹏:创新能力的培养至关重要|OceanBase 数据库大赛访谈

13.<tag-二叉树和BST基础>lt.450. 删除二叉搜索树中的节点 dbc

接力AlphaFold!星药科技重磅发布TBind-开启分子蛋白复合物结构预测新纪元

【转载】搞懂G1垃圾收集器
随机推荐
2022年理财产品还有保本保息的吗?我想投资理财但怕赔钱
Play with Web3: create your own erc-721 (NFT)
请你说说乐观锁和悲观锁,以及适用场景
. Net basic knowledge quick pass 7
简单的聊天室系统Socket实现
你不得不懂的mysql隔离级别底层
科研論文寫作
.NET基础知识快速通关11
IPO,联结一切的桥梁
Go language time Format pit
[转载] 分布式系统的“脑裂”到底是个什么玩意?
Software project management
Origin:无法导入数据,粘贴数据卡死的解决办法
Tag greedy - brush questions to prepare knowledge - greedy problem solving methods + lt.455 Distribute cookies + lt.376 Wobble sequence
ep240--all
.NET基础知识快速通关10
SIGIR 2022 | CMI: micro video recommendation combining comparative learning and multi interest mining
LR11安装报错:此计算机上缺少vc2005_sp1_with_atl_fix_redist,请安装所有缺少的必要组件,然后重新运行此安装。
Excel | App_WorkbookActive中存在错误不能设置类 Addin 的Installed属性
Several ways of traversing map