Closed HedvigS closed 3 months ago
I've spent half an hour for figuring out that it was spaces, not the uppercase categories...
I've spent half an hour for figuring out that it was spaces, not the uppercase categories...
Haha oh no! I'm sorry!
Hi, could this be fixed by refining the regular expressions in bib2df_gather.R
?
Would you accept a pull request on this?
Here's a hacky solution for desperate folks in the meantime ^^
https://hedvigsr.tumblr.com/post/702901773084524544/bib2df-bug-hacky-solution
I have the same problem. But I have a bibtex file with 3000 citation. It's extremely exhausting to add spaces before and after equal signs (=) manually. Do you know any solution to do it automatically? Do R or any tools support us to do it?
The bib
-files are plain texts, so you can do with it whatever you want. If I were you, I'd do something like this:
library(tidyverse)
read_lines("your_bib_file.bib") |>
str_replace_all("=", " = ") |> # add desired spaces
str_replace_all("\\s{2,}", " ") |> # remove double spaces in case you have it
write_lines("your_bib_file.bib")
I didn't check the code on real files, but I'm pretty confident that it should work.
@nguyentruonglt here's my scripted solution:
Here's a hacky solution for desperate folks in the meantime ^^
https://hedvigsr.tumblr.com/post/702901773084524544/bib2df-bug-hacky-solution
@nguyentruonglt here's my scripted solution:
Here's a hacky solution for desperate folks in the meantime ^^ https://hedvigsr.tumblr.com/post/702901773084524544/bib2df-bug-hacky-solution
This is the function I used:
add_spaces_for_bib2df <- function(bib_fn){
new_fn <- paste0( str_replace(bib_fn, ".bib", ""), "_sep", ".bib")
read_lines(bib_fn) %>%
str_replace_all(regex("\\=\\{"), regex(" \\= \\{")) %>%
write_lines(new_fn)
}
@giabaio I'd like to help by adjusting bib2df_gather and adjust one of the regexes and make a PR, like @nucleic-acid suggests. But, I'm struggling a bit with parsing the function and I'm concerned I'd cause problems unknowingly. I've made a suggesting in PR #59
I've discovered that when I have an entry like this:
I get a table that looks like this from bib2df::bib2df()
I've isolated the problem down to the lack of whitespaces before and after the equal sign at the field assignment. It's an easy fix, I basically just inserted whitespaces before and after every equal sign before a curly bracket, but it was a bit frustrating to debug. Can this be included in the documentation, or fixed?