Skip to contents

write_gz_text() writes text to a gzipped file through a temporary file renamed when complete: an interrupted run never leaves a truncated file that a later run would take for a finished one. read_gz_text() reads it back as one string.

Usage

write_gz_text(text, path)

read_gz_text(path, collapse = "\n")

Arguments

text

Character vector, written one element per line.

path

Character. Path of the .gz file.

collapse

Character. Separator used to join the lines when reading.

Value

write_gz_text(): path, invisibly. read_gz_text(): a string.

Examples

path <- tempfile(fileext = ".txt.gz")
write_gz_text(c("First line", "Deuxième ligne"), path)
read_gz_text(path)
#> [1] "First line\nDeuxième ligne"