File$open

File$open(mode="r") connectionarrow-up-right

Open a connection to the file. Note that by default the underlying stream won't be closed until fully consumed – it is strongly recommended to add on.exit(connection.close()) after opening the file.

You may also use the R-native open(file) to open a connection to the file.

Parameters:

mode : "r" | "rb" | "rt", default "r" Whether to read the file as text or binary. Similar to default R file behavior, defaults to text mode ("r"). "rb" is for binary mode. "rt" is an alias for "r".

Returns:

connectionarrow-up-right

Examples

# See https://redivis.com/datasets/yz1s-d09009dbb/files for example data
t <- redivis$table("demo.example_data_files:yz1s:v1_3.example_file_types:4c10")

text_file <- t$file("pandas_core.py")
con <- text_file$open()
readLines(con)

binary_file <- t$file("bogota.tiff")
con <- binary_file$open("rb")
readBin(con)

Last updated

Was this helpful?