bibtex-py - bibtex parsing module
bibtex-py is a simple bibtex parsing module for python. It is the library used in
biblio-py.
Usage
The usage of
bibtex-py is very simple; the function
parse_bib is called, and the filename of the bibfile is passed as parameter. The result is a list filled with the instances of
BibtexEntry class. For example:
from bibtex import bibparse
entries = bibparse.parse('example.bib')
The actual data of the bibtex entry can be accessed through the following fields:
- entries[n].key: The bibtex key
- entries[n].btype: The type of the entry e.g. incollection, article etc.
- entries[n].data: The actual data of the entry
for example:
print "%s\n" % ( entries[n].data['author'], )
The
BibtexEntry.__str__() is overriden in
BibtexEntry and prints out the entry in bibtex form.
@inproceedings{Spi08g,
Author = {Diomidis Spinellis},
Url = {http://www.dmst.aueb.gr/dds/pubs/talks/2008-03-InfEd/html/Spi08g.htm},
Booktitle = {4th Panhellenic Conference on Computer Science Education},
Title = {Open Source in Education},
Filename = {/Users/bkarak/devel/bkarak-svn/bibliography/reading/papers/dds.bib},
Note = {Keynote address. (In Greek.)},
Location = {Patras, Greece},
Organization = {University of Patras},
Pages = {31--32},
Editor = {Vassilis Komis},
}
Known Issues
- The parser crashes on malformed bibtex entries e.g. all data appear on a single line
- BibtexEntry.totext() and BibtexEntry.tohtml() are not implemented yet.
Download
Download version 0.8 (~1.2kb).