Dear all, Here is an answer I found.
``` library(stringi) src <- readBin("orglist-100.CSV", "raw", file.info("orglist-100.CSV")$size) src2 <- stri_encode(src, "UTF-16LE", "UTF-8") con <- textConnection(src2) answer <- read.table(con, header = TRUE, sep = ",") ``` Hope it will help someone in the future. Wush 2015-10-27 21:24 GMT+08:00 Wush Wu <wush...@gmail.com>: > Dear all, > > I tried to run the following code on 3 different OS: > > ``` > download.file(" > https://raw.githubusercontent.com/wush978/DataScienceAndR/course/RBasic-07-Loading-Dataset/orglist-100.CSV", > destfile = "orglist-100.CSV") > con <- file("orglist-100.CSV", encoding = "UTF-16LE") > src <- readLines(con) > length(src) # should be 100 > ``` > > On ubuntu and OS X, R correctly read 100 lines from the file. However, the > windows will only read the first line with the following warning message: > > ``` > Warning message: > In readLines(file("orglist-100.CSV", encoding = "UTF-16LE")) : > incomplete final line found on 'orglist-100.CSV' > ``` > > Is there any recommended way to read a local UTF-16LE file on windows? > > Thanks, > Wush > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.