For the complete documentation index, see llms.txt. This page is also available as Markdown.

File

class File

An interface for working with files on Redivis. When the constructor is called directly, a file_id must be provided. Also returned by listing files associated with a particular table or query result.

Constructors

Reference a file within a table.

Reference a file within query results.

Get a file (or directory) within a directory.

Directory$list([max_results, *, ...])

List files (and/or directories) within a directory

Query$list_files([max_results, *, ...])

List files contained within a query result. The query result must contain at least one file_id variable.

Table$list_files([max_results, *, ...])

List files contained within a file index table. The table must contain at least one file_id variable.

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)

file_contents <- text_file$read(as_text=TRUE) # Read all contents directly to memory

binary_file$download() # download to current working directory

# You can also use R's native open()
con <- open(redivis$table("table_ref")$file("filename"), "rb")

Fields

directory

A reference to the associated Directory for this file.

id

The globally unique identifier for the file, as a string.

name

The name of the file as a string, without any directory subpaths as present

path

The full path of the file

query

A reference to the Query from which this file was loaded from. Either this or table will be present.

properties

A named list containing properties associated with the file. This will always contain the following properties, derived from the file's original index table:

  • file_id (str): The globally unique id of the file

  • file_name (str): The full name of the file, including any extensions

  • size (int): The size of the file, in bytes

  • added_at (POSIXct datetime): When the file was initially uploaded to Redivis

  • md5_hash (str): The md5 checksum of the file, as a base64 string

Additionally, if the file was loaded from a table or query with additional variables, those variables' values will exist in properties.

table

A reference to the Table from which this file was loaded from.

Methods

file$download(path[, ...])

Download the file.

file$read([as_text, start_byte, end_byte])

Read the file contents into memory, either as bytes (the default) or as a string if as_text=True.

file$open([mode])

Return an open connection to the file

Last updated

Was this helpful?