bibtexparser - pyparsing.ParseException:预期的文本结尾

时间:2018-03-16 13:30:24

标签: python parsing pyparsing bibtex

我使用bibtexparser来解析bibtex文件。

import bibtexparser
with open('MetaGJK12842.bib','r') as bibfile:
    bibdata = bibtexparser.load(bibfile)

解析时我收到错误消息:

  

开始无法正确解析
@article{Frenn:EvidenceBasedNursing:1999,
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pyparsing.py", line 3183, in parseImpl
raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected end of text (at char 5773750), 
(line:47478, col:1)`

该行指的是以下bibtex条目:

@article{Frenn:EvidenceBasedNursing:1999,
    author = {Frenn, M.},
    title = {A Mediterranean type diet reduced all cause and cardiac mortality after a first myocardial infarction [commentary on de Lorgeril M, Salen P, Martin JL, et al. Mediterranean dietary pattern in a randomized trial: prolonged survival and possible reduced cancer rate. ARCH INTERN MED 1998;158:1181-7]},
    journal = {Evidence Based Nursing},
    uuid = {15A66A61-0343-475A-8700-F311B08BB2BC},
    volume = {2},
    number = {2},
    pages = {48-48},
    address = {College of Nursing, Marquette University, Milwaukee, WI},
    year = {1999},
    ISSN = {1367-6539},
    url = {},
    keywords = {Treatment Outcomes;Mediterranean Diet;Mortality;France;Neoplasms -- Prevention and Control;Phase One Excluded - No Assessment of Vegetable as DV;Female;Phase One - Reviewed by Hao;Myocardial Infarction -- Diet Therapy;Diet, Fat-Restricted;Phase One Excluded - No Fruit or Vegetable Study;Phase One Excluded - No Assessment of Fruit as DV;Male;Clinical Trials},
    tags = {Phase One Excluded - No Assessment of Vegetable as DV;Phase One Excluded - No Fruit or Vegetable Study;Phase One - Reviewed by Hao;Phase One Excluded - No Assessment of Fruit as DV},
    accession_num = {2000008864. Language: English. Entry Date: 20000201. Revision Date: 20130524. Publication Type: journal article},
    remote_database_name = {rzh},
    source_app = {EndNote},
    EndNote_reference_number = {4413},
    Secondary_title = {Evidence Based Nursing},
    Citation_identifier = {Frenn 1999a},
    remote_database_provider = {EBSCOhost},
    publicationStatus = {Unknown},
    abstract = {Question: text.},
    notes = {(0) abstract; commentary. Journal Subset: Core Nursing; Europe; Nursing; Peer Reviewed; UK \& Ireland. No. of Refs: 1 ref. NLM UID: 9815947.}
}

此条目有什么问题?

2 个答案:

答案 0 :(得分:0)

我遇到了同样的错误,并在错误中提到的行附近找到了一个条目,其中有一行像这样

...
year = {1959},
month =
}

当我删除它为我解析的空月项目时。

答案 1 :(得分:0)

似乎问题已在项目存储库中得到解决和解决(请参阅Issue 147

直到下一个版本,从git存储库安装库可以作为临时修复。

pip install --upgrade git+https://github.com/sciunto-org/python-bibtexparser.git@master