A Python package that includes a Python and Bash script to filter particular fields from a bib-file
Project description
filterbib
Package to filter out particular fields from a bib-file (e.g., exported from zotero). Cleans up the file so that only relevant fields are shown in the bibliography.
Installation
# install package
pip install git+https://github.com/gjheij/filterbib
This will place 2 scripts in the bin folder of the current anaconda environment: filter_bib and read_bib:
filter_bib: main shell script that calls uponread_bib. This is a shell script to deal withampersandsproperly, which turned out to be tricky with python.read_bib: python script that usespybtexto do most of the actual filtering.
Usage
Just entering filter_bib will pull up the help information:
(base) [heij@Jurjens-MacBook filterbib]$ filter_bib
---------------------------------------------------------------------------------------------------
filter_bib
Filter a bib-file representing a bibliography for particular fields to clean up the file. By default,
it filters out the following fields:
["abstract","note","file","extra","keywords","copyright","url","doi","urldate","issn","shorttitle",
"language","pmid"]
This part of the script is shell to deal with the ampersand's in the file ('\&' is not processed well in LaTex, so this should be changed to '\&'). It is very hard to do this
with expressions used in python. This is mainly important if you're using full journal names, rather than the abbreviations.
Arguments:
<input bib> file to be filtered
<clean bib> cleaned file
<fields to remove> comma-separated list of fields to remove
Example:
filter_bib exported_items.bib exported_items_clean.bib
filter_bib exported_items.bib exported_items_clean.bib abstract,note,extra
---------------------------------------------------------------------------------------------------------
(base) [heij@Jurjens-MacBook filterbib]$
The usage is simple: export a file from Zotero as bibtex, which generates a bib-file. This file can then be passed to filter_bib:
# simplest call
filter_bib exported_file.bib exported_file_clean.bib
By default, the following fields are removed:
fields_to_remove = [
"abstract",
"note",
"file",
"extra",
"keywords",
"copyright",
"url",
"doi",
"urldate",
"issn",
"shorttitle",
"language",
"pmid"
]
For some instances, it's nice to keep the doi-field, in which case you can copy this list and exclude doi:
filter_bib exported_items.bib exported_items_clean.bib abstract,note,file,extra,keywords,copyright,url,urldate,issn,shorttitle,language,pmid
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file filterbib-0.1.0.tar.gz.
File metadata
- Download URL: filterbib-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
581ade0b5a24dac0432148080395cb5aa29b704fa19ab6210b5690c118096ae4
|
|
| MD5 |
32473715c2b8e71cde5c80ff34d2e6d2
|
|
| BLAKE2b-256 |
6fd148ad3ade90840bf0ebc6656d55a460df124b81bdb9487af73bb2d57447b9
|
File details
Details for the file filterbib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: filterbib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7945e6aa9e0233065bb270718e9302ecc418a60fc6caed372111c1df8294764
|
|
| MD5 |
af085aad6e7f21562565b9c0842d8462
|
|
| BLAKE2b-256 |
750f599562a62f1328995d2bf8f6a11920f69290a9e49d06544ba90090a9e724
|