ropensci / bib2df

Parse a BibTeX file to a tibble
https://docs.ropensci.org/bib2df
99 stars 22 forks source link

bib variables with '.' in name #54

Open courtney-bryce-hilton opened 2 years ago

courtney-bryce-hilton commented 2 years ago

Hi, thanks for the great package.

I have found an edge-case that causes an issue with writing valid .bib files with df2bib. Specifically, I had a .bib entry that had 2 DOI values, like the following:

@article{test2022, doi = {DOI_PLACEHOLDER}, doi = {DOI_PLACEHOLDER2} }

parsing this with bib2df, and then rewriting it with df2bib, then results in something like:

@article{test2022, doi = {DOI_PLACEHOLDER}, doi.1 = {DOI_PLACEHOLDER2} }

However, '.' is not a valid character for a variable name for .bib files (I think; at least had issues knitting a .rmd).

I suspect this would be an easy fix, where you could substitute '.' in variable names with '_' or something?

Cheers

HedvigS commented 3 months ago

I think this is caused by a tidyverse assumption when getting duplicate col names, reading through bib2df code now to see where this could be fixed.

HedvigS commented 3 months ago

On second though, I'm not sure this is really a bug. You shouldn't have duplicate fields in entries to start with, so the fact that something is breaking here may actually be a good thing as it alerts you to it.

You should be getting this warning:


Some BibTeX entries may have been dropped.
            The result could be malformed.
            Review the .bib file and make sure every single entry starts
            with a '@' 

What do you think @giabaio ?