Reputation: 1518
I have the following file :
bla;bla;
0;1;2;3;4;
I want to read only the first line with fread (from data.table 1.10.0) :
fread('data/test.txt', nrows = 1, skip = 0,
colClasses = "character", autostart = 0, header = F)
It produces the following warning :
Warning message:
In fread("data/test.txt", nrows = 1, skip = 0, colClasses = "character", :
Starting data input on line 2 and discarding line 1 because it has too few or too many items to be column names or data: bla;bla;
Upvotes: 1
Views: 3699
Reputation: 331
I don't think the present fread
will work. The package description explicitly states
‘fread‘ is for regular delimited files; i.e., where every row has the same >number of columns. In future, secondary separator (sep2) may be specified within each column. Such columns will be read as type list where each cell >is itself a vector.
I tried the combination sep=";" and sep2=";", but that doesn't work.
With all this auto-detection going on I think some methods without auto-detection might be faster when you just want to read the first line.
Upvotes: 2