All software

biblio.py

A command-line BibTeX manager in Python: point it at the directories holding your .bib files, then search, count and export entries — or let it write the bibliography for a LaTeX document from the citations in it.

2006–2026PythonBibTeXLaTeX

biblio.py is a bibliography manager for people who keep their references in .bib files and their papers in a directory tree. There is no database, no server and no index to rebuild: it reads the files where they already are, every time it runs, and prints to standard output so the result can go straight into a file or a pipe.

It was written against a specific irritation, recorded on 4 January 2006: that managing a bibliography had come to mean installing a web server and a database to run a local, single-user tool. Command line, portable, and very forgiving of broken input — a malformed entry is skipped and the rest of the file is still read — is the whole design.

Getting started

Tell it where your .bib files are, once. Each path is scanned recursively on every run, so new files are picked up on their own.

$ python3 biblio.py addpath ~/bibliography
$ python3 biblio.py list
 /home/bkarak/bibliography - (OK)
$ python3 biblio.py count
Processed /home/bkarak/bibliography/reading/june-2009.bib ... found 34 entries

Total: 34 entries in 1 files

Commands

DirectiveWhat it does
addpath <dir>, listManage the directories it reads
search <keyword>Search every field of every entry, not just titles and authors
export <keys…>, key <key>Print entries as BibTeX
expfile <file>Export the keys listed in a file, one per line
texmode <files…>Export everything a LaTeX source cites
pdf <keys…>Print the path of the PDF that goes with an entry
count, new <type>, helpStatistics, a blank entry to fill in, and the usage text

Writing the bibliography for a paper

texmode reads the \cite keys out of your LaTeX source and exports exactly those entries, so the .bib beside a paper is generated rather than maintained:

pdf:
	biblio.py texmode document.tex > document.bib
	pdflatex document.tex
	bibtex document
	pdflatex document.tex
	pdflatex document.tex

PDFs beside the entries

A convention rather than a setting: the PDFs for foo.bib live in a foo/ directory beside it, each named after the entry key in lower case. When the file is there, pdf <key> prints its path and exported entries carry it as a pdf-file field, so the reference and the paper travel together.

The parser as a library

The BibTeX parser is a package of its own and is usable without the tool around it. It reads a real .bib database — @string macros, concatenation, nested braces, crossref, UTF-8 — and returns entries you can query.

from bibtex import bibparse

for entry in bibparse.parse_bib("mycollection.bib"):
    print(entry.key, entry.authors())

Two other projects picked it up: citeproc-py (external link, opens in a new tab), a CSL processor, and bib2coins (external link, opens in a new tab), which converts BibTeX to COinS metadata for embedding in a page.

Source

Requires Python 3, currently at version 0.59, BSD-licensed. This page replaces the original programs/biblio-py/ page, which was lost with the old server.