3

i have a textfile of an old spectrometer. It is encoded in "UTF-16LE" (I found this out with the readr:guess_encoding() function). I managed to read it in in base-r with:

spectra_gr2 <-  read.csv("~/some/path/spectra.csv", header = F, encoding = "UTF-16LE", fileEncoding = "UTF-16LE",  skipNul = T)

This works fine, but i want to do it using tidyverse/readr! Does anyone know how i set the two options encoding/fileEncoding in read_delim() for Example?

m4D_guY
  • 166
  • 1
  • 11

1 Answers1

9

Use it in locale

readr::read_delim("~/some/path/spectra.csv", delim = ",",
       locale = readr::locale(encoding = "UTF-16LE"), col_names = FALSE)
Nicolas2
  • 2,170
  • 1
  • 6
  • 15
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213