0

Is there a way to preserve the encoding of the double quotation marks in readr::write_csv()?

In something as simple as:

str <- tibble(x='“ABC”')
readr::write_csv(str,'a.csv')

The double quotation marks get turned into weird symbols: enter image description here

msn
  • 113
  • 3
  • The quotation used in the sample data must be quotation marks interpreted as something else in R - I get the same issue if I copy and paste your sample data, but if you simply delete the quotes then add them back in, it exports fine – jpsmith Apr 26 '22 at 20:43
  • 1
    This is due to Excel not recognizing the data as UTF-8, it's not (really) an R issue. Use `readr::write_excel_csv()` to include a BOM so Excel recognises the encoding. – Ritchie Sacramento Apr 26 '22 at 20:52

0 Answers0