有没有一种有效的方法可以在 python 中加载大型 bibtex(37000 个 bibtex 条目)文件? [英] Is there an efficient way to load a large bibtex (37000 bibtex entries) file in python?

查看:64
本文介绍了有没有一种有效的方法可以在 python 中加载大型 bibtex(37000 个 bibtex 条目)文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 python 应用程序中,我加载了大约 37'000 个 BibTeX 条目.

In my python application, I load about 37'000 BibTeX entries.

以下代码块将 .txt 文件加载为 bibtex 文件,但加载文件内容进行进一步处理需要花费大量时间.有没有更有效的方法?

The following chunk of code loads the .txt file as bibtex file, but it takes a lot of time to load the file contents for further processing. Is there a way do it more efficiently?

with open('/home/usr/Downloads/bibtexFile.txt') as bibtex_file:
    bibtex_str = bibtex_file.read()

bib_database = bibtexparser.loads(bibtex_str)

推荐答案

尝试使用 biblib ==0.1.3.文件 stats.bib 包含唯一格式的 bibtex 条目.

Try this using the biblib ==0.1.3. The file stats.bib contains uniquely formated bibtex entries.

from pybtex.database.input import bibtex
parser = bibtex.Parser()
bib_data = parser.parse_file('stats.bib')
print (bib_data.entries)

这篇关于有没有一种有效的方法可以在 python 中加载大型 bibtex(37000 个 bibtex 条目)文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆