Version 1.9.8 of data.table, released 25-NOV-2016, has a new blank.lines.skip
option to skip blank lines.
text <- "1,a
2,b
3,c
4,a
5,b
6,c"
library(data.table)
fread(text)
## V1 V2
## 1: 2 b
## 2: 3 c
## 3: 4 a
## Warning message:
## In fread("1,a
2,b
3,c
4,a
5,b
6,c") :
## Stopped reading at empty line 6 but text exists afterwards (discarded): 5,b
fread(text, blank.lines.skip=TRUE)
## V1 V2
## 1: 1 a
## 2: 2 b
## 3: 3 c
## 4: 4 a
## 5: 5 b
## 6: 6 c
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…