Open stijnh opened 2 years ago
Hopefully this workaround will help.
import bibtexparser
def export_documentset_to_bibtex(document_set, output_filename="exported_file.bib"):
"""
Exports entries from a litstudy DocumentSet to a .bib file.
Parameters:
document_set (DocumentSet): A litstudy DocumentSet containing documents to export.
output_filename (str): The name of the output .bib file (default: "exported_file.bib").
"""
# Convert DocumentSet entries to bibtexparser format
bibtex_entries = []
for entry in document_set:
bibtex_entry = entry.entry
bibtex_entries.append(bibtex_entry)
# Create a BibDatabase object and set entries
bib_database = bibtexparser.bibdatabase.BibDatabase()
bib_database.entries = bibtex_entries
# Write entries to the output BibTeX file
with open(output_filename, "w") as bibfile:
bibtexparser.dump(bib_database, bibfile)
print(f"BibTeX file exported successfully as '{output_filename}'")
Currently, there is no way to export results after loading them into memory. On possibility would be to add the ability to export a
DocumentSet
to a bibtex file.