The accepted answer to using pybtex is fraught with danger, because Pybtex does not save the bibtex format even of simple bibtex files. ( https://bitbucket.org/pybtex-devs/pybtex/issues/130/need-to-specially-represent-bibtex-markup )
Therefore, Pybtex loses bibtex information when reading and writing a simple .bib file without any changes. Users should be very careful when following the recommendations for using Pybtex.
I will also try biblib and let you know, but the accepted answer should be edited so as not to recommend pybtex.
Edit: I was able to import data using Bibtex Parser, without data loss. However, I had to compile from https://github.com/sciunto-org/python-bibtexparser , since the version installed through pip was wrong at the time. Users must ensure that pip receives the latest version.
As for export, after the data has been imported through BibTex Parser, it is placed in the dictionary and can be exported at the request of the user. BibTex Parser does not have built-in functions for exporting to common formats. Since I do not need this functionality, I have not specifically tested it. However, after importing into the dictionary, the line output can be easily converted to any citation format.
Here Pybtex and a custom style file can help. Instead, I used the stylesheet file provided by the magazine and compiled in LaTeX, but PyBtex has Python style files (but it also allows you to load .sty files). Therefore, I would recommend taking the Bibtex Parser input and moving it to PyBtex (or similar) for output in a specific style.
source share