ropensci / bib2df

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

Another format in .bib #1

Closed maelle closed 7 years ago

maelle commented 7 years ago

I encountered issues when parsing a file with entries like e.g.

@Article{RJournal:2011-1:Cook,
  author       = {Dianne Cook},
  title        = {Tips for Presenting Your Work},
  journal      = {The R Journal},
  year         = 2011,
  volume       = 3,
  number       = 1,
  pages        = {72--74},
  month        = jun,
  url          = {http://journal.r-project.org/archive/2011-1/RJournal_2011-1_Cook.pdf}
}

Fields like year, volume were NA in the final table.

I solved this rather not elegantly in https://github.com/masalmon/bib2df/commit/5bbf89d4c168eaddcc7c43ad7f3e300f9101400e (I wasn't able to find something with str_extract).

I guess my new code is not usable because I don't use str_extract (if I had I would have done a PR), do you have an idea how to solve this issue for all users?

ottlngr commented 7 years ago

Thanks for your message!

I really did not cover the case when numbers stand alone without either quotation marks or curly brackets - I simply did not know that this is valid BibTeX syntax ;)

Please don't hesitate to file a PR just because you use gsub() instead of str_extract(). Since gsub() is in base:: anyway, no additional dependencies will be needed.

maelle commented 7 years ago

Thanks for your answer!

Well I don't know if this is really valid BibTeX syntax but that's how .bib from RNews and the RJournal look like (I'm parsing them here in order to produce gender statistics). Your package really made it easier ier!

I'll prepare a PR now. There is no test in the package so what I check (well on top of R Check) is whether the current example .bib can be parsed well.

ottlngr commented 7 years ago

Thanks, that should be fine.