Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@

21. GForce grouping is again faster when running single-threaded, e.g. after `setDTthreads(1)`, [#3330](https://github.com/Rdatatable/data.table/issues/3330). The batching used to parallelize `gsum()` and `gmean()` is skipped when only one thread is available. Also, `mean()` of an `integer` or `logical` column by group no longer coerces the whole column to `double` first, which made it slower than in v1.12.0 regardless of the number of threads. Thanks @jangorecki for the benchmarks, @mattdowle for the report, and @ben-schwen for the fix.

22. `fread()` parses quoted numbers with leading or trailing whitespace as numeric rather than character, matching `read.table()` behavior, [#7946](https://github.com/Rdatatable/data.table/issues/7946). Thanks @CCIAABZ for the report and @loganb7869, @lds295, @DiamondCat106 for the PR.

### Notes

1. {data.table} now depends on R 3.5.0 (2018).
Expand Down
4 changes: 4 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -22014,3 +22014,7 @@ test(2388.24, nafill(c("a", NA, NA, "z"), type="nocb", limit=1), c("a", NA, "z",
x = seq(as.IDate("1999-01-01"), as.IDate("2027-12-31"), by="day")
test(2389.1, isoweek(x), as.integer(format(x, "%V")))
test(2389.2, isoyear(x), as.integer(format(x, "%G")))
test(2390.1, fread('"a";"b"\n"x";" 123"\n"y";" 456"\n"z";" 789"', sep=";"), data.table(a=c("x", "y", "z"), b=c(123L, 456L, 789L)))
test(2390.2, fread('"a";"b"\n"x";"123 "\n"y";"456 "\n"z";"789 "', sep=";"), data.table(a=c("x", "y", "z"), b=c(123L, 456L, 789L)))
test(2390.3, fread('"a";"b"\n"x";" 12.5 "\n"y";" 45.6 "', sep=";"), data.table(a=c("x", "y"), b=c(12.5, 45.6)))
test(2390.4, fread('"a";"b"\n" abc ";123\n" def ";456', sep=";"), data.table(a=c(" abc ", " def "), b=c(123L, 456L)))
4 changes: 4 additions & 0 deletions src/fread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,9 @@ static int detect_types(const char **pch, int ncol, bool *bumped)
}
if (*ch == quote && quote) { // && quote to exclude quote='\0' (user passed quote="")
ch++;
skip_white(&ch);
fun[tmpType[field]](&fctx);
skip_white(&ch);
if (*ch == quote) {
ch++;
skip_white(&ch);
Expand Down Expand Up @@ -2685,10 +2687,12 @@ int freadMain(freadMainArgs _args)
if (!end_of_field(tch)) tch = afterSpace; // else it is the field_end, we're on closing sep|eol and we'll let processor write appropriate NA as if field was empty
if (*tch == quote && quote) { quoted = true; tch++; }
} // else Field() handles NA inside it unlike other processors e.g. ,, is interpreted as "" or NA depending on option read inside Field()
if (quoted) skip_white(&tch);
fun[IGNORE_BUMP(thisType)](&fctx);

bool typeBump = false;
if (quoted) { // quoted was only set to true with '&& quote' above (=> quote!='\0' now)
skip_white(&tch);
if (*tch == quote) tch++;
else typeBump = true;
}
Expand Down
Loading