[datatable-help] fread always read the last line when skipping

Emilio Torres Manzanera torres at uniovi.es
Tue Apr 8 20:25:06 CEST 2014


Dear Sir,
If I use the skip option with a number greater than or equal to the number of rows of the file, it always reads the last record. It would be nice to get a NULL record in such situation.
Do you know to get this result? Thank you
Best regards
Emilio
library(data.table)
write.table(iris,"iris.csv",row.names=FALSE, col.names=FALSE)
a <- fread("iris.csv")
dim(a) # 150 records
b <- fread("iris.csv",skip=250,nrows=10) ## We skip a lot of records
b # it always return the record #150

> sessionInfo()
R version 3.0.3 (2014-03-06)
Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=es_ES.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=es_ES.UTF-8        LC_COLLATE=es_ES.UTF-8    
 [5] LC_MONETARY=es_ES.UTF-8    LC_MESSAGES=es_ES.UTF-8   
 [7] LC_PAPER=es_ES.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.9.2

loaded via a namespace (and not attached):
[1] plyr_1.8       reshape2_1.2.2 stringr_0.6.2 

-- 
=================================================
Emilio Torres Manzanera
Fac. de Comercio - Universidad de Oviedo
c/ Luis Moya 261, E-33203 Gijón (Spain)
Tel. 985 182 197 email: torres at uniovi.es
=================================================


More information about the datatable-help mailing list