Skip to content

Instantly share code, notes, and snippets.

@kzktmr
Created December 27, 2016 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzktmr/f8f6c4447ede5ee56418fe4c2b136594 to your computer and use it in GitHub Desktop.
Save kzktmr/f8f6c4447ede5ee56418fe4c2b136594 to your computer and use it in GitHub Desktop.
Export csv file that can be opened by Excel for Mac.
write_excel_mac_csv <- function(x, path, na = "NA"){
tmp <- tempfile()
readr::write_tsv(x, tmp, na = na)
path <- paste0("'", path, "'")
system(paste("(printf '\xff\xfe'; iconv -f utf-8 -t utf-16le", tmp, ") >", path))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment