Skip to content

Instantly share code, notes, and snippets.

@AlbanSagouis
Last active August 7, 2023 13:14
Show Gist options
  • Save AlbanSagouis/eec4a0866db0cb6a1f65271986d43af4 to your computer and use it in GitHub Desktop.
Save AlbanSagouis/eec4a0866db0cb6a1f65271986d43af4 to your computer and use it in GitHub Desktop.
This simple function opens UTF-16 encoded delimited tables (such as Glonaf data) in R. Separator, decimal separator and other arguments can be passed to `data.table::fread` with `...`
read_utf16_table <- function(path, ...) {
stringi::stri_read_lines(
con = path,
encoding = "UTF-16LE") |>
stringi::stri_join(collapse = "\n") |>
data.table::fread(sep = "\t", ...)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment