Repository navigation
fread fill=true and sep= provided could still read as 1-column - #2755
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2755 +/- ##
==========================================
+ Coverage 93.45% 93.46% +0.01%
==========================================
Files 61 61
Lines 12323 12358 +35
==========================================
+ Hits 11516 11551 +35
Misses 807 807
Continue to review full report at Codecov.
|
fread fill=true and sep= provided could still read as 1-column
st-pasha
left a comment
There was a problem hiding this comment.
It seems that now quote rules 2 and 3 are considered "improper" , and a warning will be issued whenever one of these rules is employed.
This is something we should be more upfront with in PR description, and in the Changelog. Note that this could be a breaking change for people who run fread under "warnings are errors" mode. Though I agree that QR=2 feels kinda like a bandaid, I'm not so sure about QR=3. After all, if a user chooses an uncommon sep (e.g. \x01), then it may be perfectly normal not to quote any fields regardless of whether they contain any quote characters or not.
Also I couldn't understand what does "self healing quote rule" mean, which was mentioned several times in comments.
Overall, I liked the reorg of the sep-detection logic: having fill=True case considered separately makes things less convoluted and more robust.
| @@ -3959,11 +3959,14 @@ test(1215, | |||
| data.table(N_ID=175931L, VISIT_DATE="2013-03-08T23:40:30", REQ_URL='http://aaa.com/rest/api2.do?api=getSetMobileSession&data={"imei":"60893ZTE-CN13cd","appkey":"android_client","content":"Z0JiRA0qPFtWM3BYVltmcx5MWF9ZS0YLdW1ydXoqPycuJS8idXdlY3R0TGBtU', REQType=2L) | |||
| ) | |||
| test(1216.1, fread('A,B,C\n1.2,Foo"Bar,"a"b\"c"d"\nfo"o,bar,"b,az""\n'), | |||
There was a problem hiding this comment.
This looks confusing: do you mean to have
'A,B,C\n1.2,Foo"Bar,"a"b"c"d"\nfo"o,bar,"b,az""\n'
or
'A,B,C\n1.2,Foo"Bar,"a"b\\"c"d"\nfo"o,bar,"b,az""\n' ?
There was a problem hiding this comment.
Good point. I'm not sure what is meant by that extra \ in that test before the \"c. It's superfluous since opening the string ' automatically escapes any " inside the string. I checked that as follows :
> identical('A,B,C\n1.2,Foo"Bar,"a"b"c"d"\nfo"o,bar,"b,az""\n',
+ 'A,B,C\n1.2,Foo"Bar,"a"b\"c"d"\nfo"o,bar,"b,az""\n')
[1] TRUE
So out of the two choices you present, the first one is what it does. Maybe the second one is what was intended.
I'll add them all in, with a comment alongside.
Yes. Other csv readers halt with 'file invalid' message. We should at least have a warning.
It is mentioned in this PR's description, point 2. Feel free to edit better wording in there as I'm not sure what you mean.
Good point. Will add something to NEWS.
"Self-healing" is meant to convey "automatic-fixing". The idea is that quote rules 2 and 3 deal with invalid files. Without them, the file would fail to read due to the otherwise invalid quote.
Yes and that's better behaviour. Such users will want to know that Note there is no way to control quote rule currently. Due in part not being sure what its parameter values should take, since the quote rule is still bedding down. It could be "auto.warn" (default), "auto.silent", or a specific rule by number or name. Currently user can turn off the new warning with
Yes and that's why quote rule 3 exists. But that is unusual and should be warned about because it's more likely something is wrong in a regular comma-separated-file. If file is using unusual sep for that reason without any quoted fields, but where the field does contain quotes, the warning now suggests to set |
…r quote='' added for no warning when unusual sep used without quoting
|
@st-pasha Have addressed your comments and this PR is complete I hope. Please re-review. |
Closes #2666
The root cause was the fallback to single-column input that happened in all cases.