From 3530533c4a57eb386cf78b9af566b60bc462863a Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 10 Dec 2024 10:34:19 +0800 Subject: [PATCH] Progress deprecation of autostart --- NEWS.md | 2 ++ R/fread.R | 4 ++-- inst/tests/tests.Rraw | 4 ++-- man/fread.Rd | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 885eb56c5..ce1789e73 100644 --- a/NEWS.md +++ b/NEWS.md @@ -137,6 +137,8 @@ rowwiseDT( 6. `measurev()` was implemented and documented in v1.15.0, for use within `melt()`, and it is now exported (dependent packages can now use without a NOTE from CRAN check). +7. Deprecation of `fread(autostart=)` has been upgraded to an error. It has been warning since v1.11.0 (6 years ago). The argument will be removed in the next release. + # data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024) ## BUG FIXES diff --git a/R/fread.R b/R/fread.R index 64247d7ac..5bf2a9784 100644 --- a/R/fread.R +++ b/R/fread.R @@ -7,7 +7,7 @@ showProgress=getOption("datatable.showProgress",interactive()), data.table=getOp nThread=getDTthreads(verbose), logical01=getOption("datatable.logical01",FALSE), logicalYN=getOption("datatable.logicalYN", FALSE), keepLeadingZeros=getOption("datatable.keepLeadingZeros",FALSE), -yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC") +yaml=FALSE, autostart=NULL, tmpdir=tempdir(), tz="UTC") { if (missing(input)+is.null(file)+is.null(text)+is.null(cmd) < 3L) stopf("Used more than one of the arguments input=, file=, text= and cmd=.") input_has_vars = length(all.vars(substitute(input)))>0L # see news for v1.11.6 @@ -124,7 +124,7 @@ yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC") input = file } - if (!missing(autostart)) warningf("'autostart' is now deprecated and ignored. Consider skip='string' or skip=n"); + if (!is.null(autostart)) stopf("'autostart' is deprecated. Consider skip='string' or skip=n. This argument will be removed in the next release."); if (is.logical(colClasses)) { if (!allNA(colClasses)) stopf("colClasses is type 'logical' which is ok if all NA but it has some TRUE or FALSE values in it which is not allowed. Please consider the drop= or select= argument instead. See ?fread.") colClasses = NULL diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 657478c61..1c3d0394d 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -2908,7 +2908,7 @@ test(966, fread(input, colClasses=list(character=2:4)), data.table(A=1:2, B=c("f # Character input more than 4096 bytes (used to be passed through path.expand which imposed the limit), #2649 test(967, nrow(fread( strrep('a\tb\n', 10000L), header=FALSE)), 10000L) -# Test fread warns about removal of any footer (and autostart skips up over it) +# Test fread warns about removal of any footer (and skip= skips up over it) test(968, fread("A,B\n1,3\n2,4\n\nRowcount: 2\n"), data.table(A=1:2,B=3:4), warning="Discarded single-line footer.*Rowcount: 2") test(969, fread("A,B\n1,3\n2,4\n\n\nRowcount: 2"), data.table(A=1:2,B=3:4), warning="Discarded single-line footer.*Rowcount: 2") test(970, fread("A,B\n1,3\n2,4\n\n\nRowcount: 2\n\n"), data.table(A=1:2,B=3:4), warning="Discarded single-line footer.*Rowcount: 2") @@ -13184,7 +13184,7 @@ test(1925.10, as.ITime(x), structure(c(12L, 67L), class="ITime")) test(1925.11, as.ITime(x, ms='nearest'), structure(c(12L, 68L), class="ITime")) test(1925.12, as.ITime(x, ms='ceil'), structure(c(13L, 68L), class="ITime")) -test(1936.1, fread("A,B\n1,3\n2,4", autostart=1), data.table(A=1:2, B=3:4), warning="autostart.*deprecated.*Consider skip") +test(1936.1, fread("A,B\n1,3\n2,4", autostart=1), error="autostart.*deprecated.*Consider skip") if (.Platform$OS.type == "unix") test(1936.2, is.data.table(fread("ls ."))) # add helpful error to %between% diff --git a/man/fread.Rd b/man/fread.Rd index 00a24dab3..dc45b0205 100644 --- a/man/fread.Rd +++ b/man/fread.Rd @@ -25,7 +25,7 @@ nThread=getDTthreads(verbose), logical01=getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS logicalYN=getOption("datatable.logicalYN", FALSE), keepLeadingZeros = getOption("datatable.keepLeadingZeros", FALSE), -yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC" +yaml=FALSE, autostart=NULL, tmpdir=tempdir(), tz="UTC" ) } \arguments{ @@ -65,7 +65,7 @@ yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC" \item{logicalYN}{If TRUE a column containing only Ys and Ns will be read as logical, otherwise as character.} \item{keepLeadingZeros}{If TRUE a column containing numeric data with leading zeros will be read as character, otherwise leading zeros will be removed and converted to numeric.} \item{yaml}{ If \code{TRUE}, \code{fread} will attempt to parse (using \code{\link[yaml]{yaml.load}}) the top of the input as YAML, and further to glean parameters relevant to improving the performance of \code{fread} on the data itself. The entire YAML section is returned as parsed into a \code{list} in the \code{yaml_metadata} attribute. See \code{Details}. } - \item{autostart}{ Deprecated and ignored with warning. Please use \code{skip} instead. } + \item{autostart}{ Deprecated. Please use \code{skip} instead. } \item{tmpdir}{ Directory to use as the \code{tmpdir} argument for any \code{tempfile} calls, e.g. when the input is a URL or a shell command. The default is \code{tempdir()} which can be controlled by setting \code{TMPDIR} before starting the R session; see \code{\link[base:tempfile]{base::tempdir}}. } \item{tz}{ Relevant to datetime values which have no Z or UTC-offset at the end, i.e. \emph{unmarked} datetime, as written by \code{\link[utils:write.table]{utils::write.csv}}. The default \code{tz="UTC"} reads unmarked datetime as UTC POSIXct efficiently. \code{tz=""} reads unmarked datetime as type character (slowly) so that \code{as.POSIXct} can interpret (slowly) the character datetimes in local timezone; e.g. by using \code{"POSIXct"} in \code{colClasses=}. Note that \code{fwrite()} by default writes datetime in UTC including the final Z and therefore \code{fwrite}'s output will be read by \code{fread} consistently and quickly without needing to use \code{tz=} or \code{colClasses=}. If the \code{TZ} environment variable is set to \code{"UTC"} (or \code{""} on non-Windows where unset vs `""` is significant) then the R session's timezone is already UTC and \code{tz=""} will result in unmarked datetimes being read as UTC POSIXct. For more information, please see the news items from v1.13.0 and v1.14.0. } }