Is there a reliable python library for taking a BibTex entry and outputting it into specific formats?

War Gravy picture War Gravy · Jun 11, 2015 · Viewed 9.8k times · Source

I'm developing using Python and Django for a website. I want to take a BibTex entry and output it in a view in 3 different formats, MLA, APA, and Chicago. Is there a library out there that already does this or am I going to have to manually do the string formatting?

Answer

tatlar picture tatlar · Jun 11, 2015

There are the following projects:

If you need complex parsing and output, Pybtex is recommended. Example:

>>> from pybtex.database.input import bibtex
>>> parser = bibtex.Parser()
>>> bib_data = parser.parse_file('examples/foo.bib')
>>> bib_data.entries.keys()
[u'ruckenstein-diffusion', u'viktorov-metodoj', u'test-inbook', u'test-booklet']
>>> print bib_data.entries['ruckenstein-diffusion'].fields['title']
Predicting the Diffusion Coefficient in Supercritical Fluids

Good luck.