I have a text file that is UTF-16LE encoded with CRLF line endings and '@' as field separators that I want to read in R on a Linux system. Which would be fine as

read.table("foo.txt", file.encoding = "UTF-16LE", sep = "@", ...)

*except* that the data may contain the LF character which R treats as end-of-line and then barfs that there are too few elements on that line.

Any suggestions for how to process this one efficiently in R? There is probably a solution using read.table(..., nrows = 1, ...) to get the header, split it on '@', build a list with that many character(0) elements, and then using scan(..., multi.line=TRUE, ...) ..... but that all sounds very complicated.

Allan.

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to