From 3764969747d217d982738de67940c3c8b54d0600 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Mon, 10 May 2021 17:46:06 -0700 Subject: [PATCH] use writeLines for fread(text=.) (#4805) --- R/fread.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/fread.R b/R/fread.R index a36cbfda2..b8271ce0c 100644 --- a/R/fread.R +++ b/R/fread.R @@ -36,7 +36,7 @@ yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC") if (!is.character(text)) stop("'text=' is type ", typeof(text), " but must be character.") if (!length(text)) return(data.table()) if (length(text) > 1L) { - cat(text, file=(tmpFile<-tempfile(tmpdir=tmpdir)), sep="\n") # avoid paste0() which could create a new very long single string in R's memory + writeLines(text, tmpFile<-tempfile(tmpdir=tmpdir)) # avoid paste0() which could create a new very long single string in R's memory file = tmpFile on.exit(unlink(tmpFile), add=TRUE) } else {