Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upfwrite/fread single column input with NA -vs- empty lines #2106
Comments
There are no separators in any line, and the last line is blank. Absent separators,
One potential fix: add a dummy column:
Now |
|
@MichaelChirico Side note: to cat it to the console, just use
So it can be reproduced like...
Yeah, I'm inclined towards saying the file should be written better if it wants blank lines read as NA (rather than reconfigure fread to treat this one-column case specially). I mean:
|
|
@franknarf1 nice, the default to write to And I like your fix better, but not sure if it's the user's responsibility to handle a case like that, or if |
|
The warning message is there. And there are arguments to control it.
Perhaps "Consider fill=TRUE and blank.lines.skip=TRUE" should be added to the warning message? (TODO1) |
|
Also the empty lines can be controlled in
|
|
I just read again and understood @MichaelChirico's comment now :
Yes - nice idea! Happy to make that change. (TODO2) |
|
Closed by #2451 |
|
Great.
|
|
Now that |
I create a toy example.
temp <- data.table(a=c(1,NA,2,3,999,NA))
I save it:
fwrite(temp, "temp.csv", quote=FALSE, sep=",", append=F)
and read it again:
my <- fread("temp.csv", stringsAsFactors=F)
As you can see only the first line is read.
I don't know if it's a problem with fread or with fwrite's output file.