Skip to content

Commit d0956f3

Browse files
manual entry + news
1 parent 8424176 commit d0956f3

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969

7070
15. New function `isoyear()` has been implemented as a complement to `isoweek()`, returning the ISO 8601 year corresponding to a given date, [#7154](https://github.com/Rdatatable/data.table/issues/7154). Thanks to @ben-schwen and @MichaelChirico for the suggestion and @venom1204 for the implementation.
7171

72+
16. `fwrite()` gains `select` argument to write only specified columns, avoiding temporary object creation for memory efficiency, [#4177](https://github.com/Rdatatable/data.table/issues/4177). For `data.table` objects, this uses `.shallow()` to create shallow copies without data duplication. Thanks to @artidataio for feature request, @ColeMiller1 for suggesting implementation and @Mukulyadav2004 for the implementation.
73+
7274
### BUG FIXES
7375

7476
1. `fread()` no longer warns on certain systems on R 4.5.0+ where the file owner can't be resolved, [#6918](https://github.com/Rdatatable/data.table/issues/6918). Thanks @ProfFancyPants for the report and PR.

R/fwrite.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fwrite = function(x, file="", append=FALSE, quote="auto",
1414
bom = FALSE,
1515
verbose=getOption("datatable.verbose", FALSE),
1616
encoding = "",
17-
select) {
17+
select = NULL) {
1818
na = as.character(na[1L]) # fix for #1725
1919
if (length(encoding) != 1L || !encoding %chin% c("", "UTF-8", "native")) {
2020
stopf("Argument 'encoding' must be '', 'UTF-8' or 'native'.")
@@ -29,7 +29,7 @@ fwrite = function(x, file="", append=FALSE, quote="auto",
2929
compressLevel = as.integer(compressLevel)
3030

3131
# Handle select argument using .shallow()
32-
if (!missing(select)) {
32+
if (!null(select)) {
3333
if (is.data.table(x)) {
3434
cols = colnamesInt(x, select)
3535
x = .shallow(x, cols)

man/fwrite.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fwrite(x, file = "", append = FALSE, quote = "auto",
6262
\item{bom}{If \code{TRUE} a BOM (Byte Order Mark) sequence (EF BB BF) is added at the beginning of the file; format 'UTF-8 with BOM'.}
6363
\item{verbose}{Be chatty and report timings?}
6464
\item{encoding}{ The encoding of the strings written to the CSV file. Default is \code{""}, which means writing raw bytes without considering the encoding. Other possible options are \code{"UTF-8"} and \code{"native"}. }
65+
\item{select}{Vector of column names or column numbers specifying which columns to include. When \code{NULL} (default), all columns are selected. This avoids creating temporary subsets for memory efficiency.}
6566
}
6667
\details{
6768
\code{fwrite} began as a community contribution with \href{https://github.com/Rdatatable/data.table/pull/1613}{pull request #1613} by Otto Seiskari. This gave Matt Dowle the impetus to specialize the numeric formatting and to parallelize: \url{https://h2o.ai/blog/2016/fast-csv-writing-for-r/}. Final items were tracked in \href{https://github.com/Rdatatable/data.table/issues/1664}{issue #1664} such as automatic quoting, \code{bit64::integer64} support, decimal/scientific formatting exactly matching \code{write.csv} between 2.225074e-308 and 1.797693e+308 to 15 significant figures, \code{row.names}, dates (between 0000-03-01 and 9999-12-31), times and \code{sep2} for \code{list} columns where each cell can itself be a vector.

0 commit comments

Comments
 (0)