Skip to content

Option to write UTF-8-BOM in write_csv() (for excel) #375

@zross

Description

@zross

I've converted from write.csv to write_csv for a few projects and am finding that write_csv handles special characters differently and results in very odd looking results when opened in Excel. I'm guessing it's related to writing to UTF-8? Here is an example where the dash is an en dash:

dat <- data.frame(a=1:2, b=c("reported – estimate", "updated – estimate"))

write.csv(dat, "d:/junk/writecsv.csv")
readr::write_csv(dat, "d:/junk/readr.csv")

The file from write.csv looks perfect in Excel and when looking at the raw data. The example from readr looks like this in raw:

image

and this in Excel:

image

In my own use case I'm taking advantage of the format_csv function so it's not an easy conversion to go back to write.csv -- I'd love to continue using readr.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions