diff --git a/R/fread.R b/R/fread.R index 2ae9484e4..b948eb9eb 100644 --- a/R/fread.R +++ b/R/fread.R @@ -46,8 +46,9 @@ fread <- function(input="",sep="auto",sep2="auto",nrows=-1L,header="auto",na.str # In text mode on Windows-only, R doubles up \r to make \r\r\n line endings. mode="wb" avoids that. See ?connections:"CRLF" input = tt } else if (input == "" || length(grep('\\n|\\r', input)) > 0) { - # if text input + # text input } else if (!file.exists(input)) { + if (length(grep(' ', input)) == 0) stop("File '",input,"' does not exist. Include one or more spaces to consider the input a system command.") tt = tempfile() on.exit(unlink(tt), add = TRUE) if (.Platform$OS.type == "unix") { diff --git a/README.md b/README.md index 77bd4bdaf..3bfaba7b4 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ * doubled quotes ("") inside quoted fields including if immediately followed by an embedded newline. Thanks to James Sams for reporting, [#489](https://github.com/Rdatatable/data.table/issues/489). * quoted fields with embedded newlines in the lines used to detect types, [#810](https://github.com/Rdatatable/data.table/issues/810). Thanks to Vladimir Sitnikov for the scrambled data file which is now included in the test suite. * when detecting types in the middle and end of the file, if the jump lands inside a quoted field with (possibly many) embedded newlines, this is now detected. + * if the file doesn't exist the error message is clearer ([#486](https://github.com/Rdatatable/data.table/issues/486)) + * system commands are now checked to contain at least one space 6. `as.data.table.list` with list input having 0-length items, e.g. `x = list(a=integer(0), b=3:4)`. `as.data.table(x)` recycles item `a` with `NA`s to fit the length of the longer column `b` (length=2), as before now, but with an additional warning message that the item has been recycled with `NA`. Closes [#847](https://github.com/Rdatatable/data.table/issues/847). Thanks to @tvinodr for the report. This was a regression from 1.9.2. diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 8115da41d..bc44a2b77 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -5566,10 +5566,7 @@ test(1451.6, ans1[c(3,3)], fans2(DT, c("V3", "V3"))) # using duplicate co test(1451.7, shallow(DT, integer(0)), null.data.table()) # length-0 input work as intended as well. test(1451.8, shallow(DT, character(0)), null.data.table()) # length-0 input work as intended as well. - -# > fread("notexist.csv") -# sh: 1: nonfile.csv: not found -# Error in fread("nonfile.csv") : File is empty: /dev/shm/file54e46ccdb63 +test(1452, fread("notexist.csv"), error="File 'notexist.csv' does not exist. Include one or more spaces to consider the input a system command.") ##########################