Last active
May 20, 2025 07:14
-
-
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 `...`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| read_utf16_table <- function(path, sep = "\t", ...) { | |
| stringi::stri_read_lines( | |
| con = path, | |
| encoding = "UTF-16LE") |> | |
| stringi::stri_join(collapse = "\n") |> | |
| data.table::fread(sep = sep, ...) | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An elegant solution to an infuriating problem. Worked well, thank you.