BibCleaner
BibCleaner is a Python package designed to parse, clean, and format .bib files for better LaTeX bibliography management. It ensures consistency in formatting, validates DOIs, and helps detect missing or incorrect fields. It facilitates integrations between citation management tools such as zotero and latex editor.
Features
Parses .bib files and structures them properly
Cleans and formats author names (handles capitalization, prefixes like "van", "de", etc.)
Ensures proper title capitalization (preserving LaTeX commands)
Customize fields and remove duplicate authors
Detects and fixes formatting issues in pages, DOIs, dates, etc.
Validates DOIs and warns if they are broken
Auto-generates citation keys based on author, title, and year
Categorizes warnings:
- Critical Issues: Missing author, title, year, etc.
- Soft Warnings: Broken DOI, minor inconsistencies
Installation
Install the package using pip:
pip install bibcleaner
Or, clone the repository and install it manually:
git clone https://github.com/harryziyuhe/bibcleaner.git
cd bibcleaner
pip install .
Usage
Basic Usage (CLI)
from bibcleaner import BibCleaner
cleaner = BibCleaner("references.bib")
cleaner.process()
cleaner.save_as_bib("cleaned_references.bib")
Example Input & Output
Example .bib File (Before Cleaning)
@article{einstein1923,
author = "albert einstein",
title = "the theory of relativity",
journal = "journal of physics",
year = "1923",
doi = "10.1000/xyz123"
}
Cleaned Output
@article{Einstein_Theory_1923,
author = {Albert Einstein},
title = {The Theory of Relativity},
journal = {Journal of Physics},
year = {1923},
doi = {10.1000/xyz123}
}
Warning Output
Critical Issues Found:
Missing required field 'author' in @article{sample2024}
Soft Warnings:
DOI '10.1000/broken' in @article{sample2023} may be broken (HTTP 404).
Advanced Features
Cleaning Options
You can specify which fields to keep when cleaning. Example:
keep_fields = {
"article": ["author", "title", "journal", "year"],
"book": ["author", "title", "publisher", "year"]
}
cleaner = BibCleaner("references.bib", keep_fields)
cleaner.process()
Export to JSON
cleaner.save_as_json("cleaned_references.json")
License
This project is licensed under the MIT License.
See LICENSE for details.
Contact
For suggestions or issues, feel free to open an issue on GitHub or contact zih028@ucsd.edu
Release files for cleanbib 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cleanbib-0.1.1.tar.gz | 10.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cleanbib-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / cleanbib-0.1.1.tar.gz
| Download URL | cleanbib-0.1.1.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b44af4cf6717509b6743b862077ab0bf9c6cd5a278bb59191b698beec8476d09
|
|
BLAKE2b-256 checksum How to use checksums |
4aa4bd157bb318a966074f41f56cce3ff0e7cfdc1fdfd19716b4f44ea5333a30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|
Release files / cleanbib-0.1.1-py3-none-any.whl
| Download URL | cleanbib-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac8e1048c5b98e29b159364757b38f4c8a4061959c2ed12331889b4b036db345
|
|
BLAKE2b-256 checksum How to use checksums |
141b88d298e2a2a96fe66837510630f857cc86cae28eb5eadfbbe7d6b903f405
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.28.1
|