I have tab-delimited files with this kind of table:
mytext <- "colA colB colС colD
ID1 valB1 valC1
ID2 valB2 valC2
ID3 valB3 valC3 valD3
ID4 valB4 valC4 valD4"
First line contains the header with fixed number of fields, and next lines contain not more than this number of fields, but sometimes less, i.e. last fields can be missing. In read.csv()
, I can just add fill=TRUE
and it works perfectly, but fread()
does not have this option. Even if I explicitly indicate, for example, header=TRUE, skip='colA'
- fread()
skips first lines including even the header; it makes line 'ID3' a header. What is recommended solution for this? I would like to avoid double conversion data.table(read.csv(...))
as it's quite slow.