It looks like if the second line in the file is empty, the column names will not be read. I've played with switches such as header, skip, from the documentation but can't get it to work.
In case the second line in my file is empty, how to ignore this fact and still read the first line as column names?
the second line is empty:
> fread('c1 c2\n\n1 2\n3 4\n')
V1 V2
1: 1 2
2: 3 4
the second line is not empty:
> fread('c1 c2\n1 2\n3 4\n')
c1 c2
1: 1 2
2: 3 4
The current version of data.table
(1.9.8+) adds a blank.lines.skip
argument that seems to resolve this problem:
fread('c1 c2\n\n1 2\n3 4\n',blank.lines.skip = TRUE)
# c1 c2
# 1: 1 2
# 2: 3 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With