3

When saving data in R, if you use write.csv() with default arguments you get a quoted csv file like this:

"a","b"
"c","d"

However, if you use readr::write_csv() you get by default (and it looks there's no option to change this) an unquoted csv:

a,b
c,d

If you want a reproducible example, try

write.csv(mtcars)
readr::write_csv(mtcars)

As of why I'd like to use write_csv over write.csv, aside from speed, it allows me to have LF line ending on Windows instead of switching from LFCR using Notepad++ or saving the file as a binary file.

mickkk
  • 1,172
  • 2
  • 17
  • 38
  • 2
    The `?write_csv` documentation states *"Values are only quoted if needed: if they contain a comma, quote or newline,*" and you are correct: there is no option to change that. `write.csv` will let you specify an end of line character. `data.table::fwrite` will as well, and will probably be even faster than `write_csv`. – Gregor Thomas Mar 05 '18 at 19:45
  • write.csv will let you specify an end of line character but on Windows that is always CRLF even if you set it to LF... I'm mostly interested in the default LF ending but I'd rather not change the output (even if it is just the quotes) – mickkk Mar 05 '18 at 21:08

0 Answers0