[R] Failed to read UTF-16LE file on Windows

Wush Wu wush978 at gmail.com
Tue Oct 27 14:24:09 CET 2015


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]]



More information about the R-help mailing list