Skip to contents

The format is set on the file objects inside the list so that the file object can be used to call a write method. See write_stream().

Usage

format_stream(
  x,
  type = c("fst", "feather", "qs", "rds"),
  set_ext = TRUE,
  warn = FALSE
)

Arguments

x

A file_stream object.

type

The file format type; if feather is chosen, then a check will be made to ensure the arrow package is loaded.

set_ext

If TRUE, the existing extension (if it exists) is stripped and a new extension is added based on the value of type.

warn

If TRUE a warning will be issued in case the output format is set but there is no directory path associated with the file spot in x[[1]].

Value

x is returned with a new class attribute reflecting the expected output format (fst, feather (arrow), qs or rds).

Examples

fs <- new_stream(2)
fs <- format_stream(fs, "fst")
fs[[1]]
#> $i
#> [1] 1
#> 
#> $file
#> [1] "1-2.fst"
#> 
#> $x
#> [1] 1
#> 
#> attr(,"file_set_item")
#> [1] TRUE
#> attr(,"class")
#> [1] "stream_format_fst" "list"             

format_is_set(fs[[1]])  
#> [1] TRUE