-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fread(fill=TRUE) fills character fields with empty strings instead of NAs #2524
Comments
Have been discussing with Pasha about this. He'd like filled character columns ( Any views out there? |
I tend to agree with Pasha, but I don't understand this sentence:
Would you mind paraphrasing? |
Consider this file:
If
However when
|
Interesting. I think I agree with Pasha. To me it seems immediately clear that the second row should be The ambiguity comes from how to treat Maybe we can add some output to |
At the risk of adding complexity, but a way to avoid this decision would be to let > fread("A,B,C,D\n1,foo,bar,5\n2\n3,,baz",
fill=list(logical = NA, integer = 7L, character = ""),
na.strings="?")
A B C D
1: 1 foo bar 5
2: 2 7
3: 3 baz 7 On the broader point, how important is it that |
Great points. I'm not so sure either on the importance of fread/fwrite being inverses of each other, by default. If saving from R and back into R needs to be preserving, wouldn't you use a binary format for that? I like the In short, as long as by default :
That's the main thing to me. Think everyone agrees on that. That's not the case now and needs PR #2652 to make that happen. Since Pasha has approved that one now, I'll request @MichaelChirico, @HughParsonage, @arunsrinivasan and @jangorecki to add your approvals too please since it's major one at the top of NEWS (but it doesn't actually change any default behaviour yet). |
FWIW, I would support Matt's view -- if the user has supplied explicit Reason: This is a broader issue, not just when the file has This also has an implication re I like MichaelChirico's suggestion for notifying the user that |
it might be beneficial to explicitly state somewhere that fread and fwrite are not intended to support data-type stable round-tripping persistent storage. these functions are so so fast and convenient, that I fell into the trap of trying to do this without thinking about the suitability of this solution |
Unless of course schema is carried together, either as function arguments or CSVY header. |
Test case:
Expected output:
The text was updated successfully, but these errors were encountered: