Skip to content

Instantly share code, notes, and snippets.

View TomWagg's full-sized avatar

Tom Wagg TomWagg

View GitHub Profile
@TomWagg
TomWagg / removed_unused_bibs.py
Created June 11, 2023 18:52
bib reducer: Reduce and combine multiple .bib files to a single file with only *cited* entries
import re
import argparse
def collect_all_bibs(bib_files):
# regex for anything that matches "@[some word]{[something],"
bibtex_key_regex = r"@\w*{.*(?=\,)"
# convert strings to lists in case only one file
if isinstance(bib_files, str):
bib_files = [bib_files]