Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_delim clearing (non-empty) files with append = TRUE #1408

Closed
cljacobs opened this issue Jun 22, 2022 · 0 comments · Fixed by tidyverse/vroom#451
Closed

write_delim clearing (non-empty) files with append = TRUE #1408

cljacobs opened this issue Jun 22, 2022 · 0 comments · Fixed by tidyverse/vroom#451
Assignees

Comments

@cljacobs
Copy link

As per the title, the write_delim function will delete all the previous contents of a file, even if append = TRUE if provided an empty data.frame (tibble, etc) as the primary argument.

readr version: 2.1.2

A minimal example, below.

library(readr)
cat("some text in a file\n",file="empty.txt")
write_tsv(data.frame(),file="empty.txt",append=TRUE)
read_lines("empty.txt")
# character(0)

compare to:

library(readr)
cat("some text in a file\n",file="nonempty.txt")
write_tsv(data.frame(a=1:3,b=LETTERS[1:3]),file="nonempty.txt",append=TRUE)
read_lines("nonempty.txt")
# [1] "some text in a file"     "1\tA"    "2\tB"    "3\tC" 

or:

library(readr)
cat("some text in a file\n",file="nonempty.txt")
write.table(data.frame(),file="test.txt",append=TRUE,col.names=FALSE)
read_lines("nonempty.txt")
# [1] "some text in a file"
@sbearrows sbearrows self-assigned this Jul 13, 2022
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jun 17, 2023
# vroom 1.6.3

# vroom 1.6.2

* No user-facing changes.

# vroom 1.6.1

* `str()` now works in a colorized context in the presence of a column
  of class `integer64`, i.e. parsed with `col_big_integer()` (@bart1,
  #477).

* The embedded implementation of the Grisu algorithm for printing
  floating point numbers now uses `snprintf()` instead of `sprintf()`
  and likewise for vroom's own code (@jeroen, #480).

# vroom 1.6.0

* `vroom(col_select=)` now handles column selection by numeric
  position when `id` column is provided (#455).

* `vroom(id = "path", col_select = a:c)` is treated like `vroom(id =
  "path", col_select = c(path, a:c))`. If an `id` column is provided,
  it is automatically included in the output (#416).

* `vroom_write(append = TRUE)` does not modify an existing file when
  appending an empty data frame. In particular, it does not overwrite
  (delete) the existing contents of that file
  (tidyverse/readr#1408, #451).

* `vroom::problems()` now defaults to `.Last.value` for its primary
  input, similar to how `readr::problems()` works (#443).

* The warning that indicates the existence of parsing problems has
  been improved, which should make it easier for the user to follow-up
  (tidyverse/readr#1322).

* `vroom()` reads more reliably from filepaths containing non-ascii
  characters, in a non-UTF-8 locale (#394, #438).

* `vroom_format()` and `vroom_write()` only quote values that contain
  a delimiter, quote, or newline. Specifically values that are equal
  to the `na` string (or that start with it) are no longer quoted
  (#426).

* Fixed segfault when reading in multiple files and the first file has
  only a header row of column names, but subsequent files have at
  least one row (#430).

* Fixed segfault when `vroom_format()` is given an empty data frame
  (#425)

* Fixed a segfault that could occur when the final field of the final
  line is missing and the file also does not end in a newline (#429).

* Fixed recursive garbage collection error that could occur during
  `vroom_write()` when `output_column()` generates an ALTREP vector
  (#389).

* `vroom_progress()` uses `rlang::is_interactive()` instead of
  `base::interactive()`.

* `col_factor(levels = NULL)` honors the `na` strings of `vroom()` and
  its own `include_na` argument, as described in the docs, and now
  reproduces the behaviour of readr's first edition parser (#396).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants