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_streamobject.- type
The file format type; if
featheris chosen, then a check will be made to ensure thearrowpackage is loaded.- set_ext
If
TRUE, the existing extension (if it exists) is stripped and a new extension is added based on the value oftype.- warn
If
TRUEa warning will be issued in case the output format is set but there is no directory path associated with thefilespot inx[[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