[R] How long does skipping in read.table take

Gabor Grothendieck ggrothendieck at gmail.com
Sat Oct 23 14:22:09 CEST 2010


On Sat, Oct 23, 2010 at 7:44 AM, Dimitri Liakhovitski
<dimitri.liakhovitski at gmail.com> wrote:
> Gabor,
> maybe some of my code is wrong (I don't know sql at all). I tried the
> following with just a few lines as a test:
> library(sqldf)
> mydata<-read.csv.sql("myfile.txt",sep="|", sql = "select * from file 200, 100")

"limit" was missing in my post.  It should be:

   mydata<-read.csv.sql("myfile.txt",sep="|", sql = "select * from
file limit 200, 100")

Usually hangs mean that eol is wrong.  Also try not specifying eol as
well as eol = "\n", eol = "\r" and eol = "\r\n" and see if any of
those work (after correcting the missing "limit").

You can also verify what the end of line characters are directly by
reading in sufficient characters in binary so that at least one line
is read in. If the first line has fewer than 1000 characters then, in
R:

L <- readBin("myfile.csv", "raw", 1000)
rawToChar(L)

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list