Skip to content

fwrite append not working with csv.gz #6863

@ChristK

Description

@ChristK

Hi there

Since the latest update to 1.17.0, using fwrite with append = TRUE, have stopped working for compressed files.

MRE

library(data.table) 
DT <- data.table(x = 1L)
fwrite(DT, "test.csv.gz")
fwrite(DT, "test.csv.gz", append = TRUE)
fread("test.csv.gz")[] # Should have 2 rows
 #        x
 #  <int>
 #  1:     1

Everything works as expected with uncompressed files

fwrite(DT, "test.csv")
fread("test.csv")[]
fwrite(DT, "test.csv", append = TRUE)
fread("test.csv")[] # correct!

#        x
#    <int>
# 1:     1
# 2:     1
 sessionInfo()

R version 4.4.3 (2025-02-28)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
 [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/London
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] data.table_1.17.0

loaded via a namespace (and not attached):
 [1] compiler_4.4.3    magrittr_2.0.3    R6_2.6.1          cli_3.6.4         promises_1.3.2   
 [6] later_1.4.1       tools_4.4.3       Rcpp_1.0.14       bspm_0.5.7        R.methodsS3_1.8.2
[11] jsonlite_1.9.1    httpuv_1.6.15     R.utils_2.13.0    rlang_1.1.5       R.oo_1.27.0      

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions