Pybtex Does Not Recogonize Bibtex Entry
I'm creating a publications database which allows users to enter bibtex entries which I then parse and store in a db. Right now, I'm having trouble parsing the bibtex entries. I'm
Solution 1:
To parse from a string, use StringIO in combination with parse_stream:
import pybtex.database.input.bibtex
from StringIO import StringIO
defbibtex_string_to_data(s):
parser = pybtex.database.input.bibtex.Parser()
return parser.parse_stream(StringIO(s))
print bibtex_string_to_data("""
@article{article,
author = {Peter Adams},
title = {The title of the work},
journal = {The name of the journal},
year = 1993,
number = 2,
pages = {201-213},
month = 7,
note = {An optional note},
volume = 4
}
""")
which gives (reformatted for readability):
BibliographyData(entries=OrderedCaseInsensitiveDict({
'article': Entry(
'article',
fields={
'volume': '4',
'title': 'The title of the work',
'journal': 'The name of the journal',
'number': '2',
'month': '7',
'note': 'An optional note',
'year': '1993',
'pages': '201-213'},
persons={
'author': [Person(u'Adams, Peter')]})
}), preamble=[])
Post a Comment for "Pybtex Does Not Recogonize Bibtex Entry"