Working with non-tabular data

Load a single file

library(redivis)

# References the file bogota.tiff at https://redivis.com/datasets/yz1s-d09009dbb/files/4c10-d8rqhswh8.zz7AB9NJB2ctNpDGKbRD7w
file <- redivis::file("4c10-d8rqhswh8.zz7AB9NJB2ctNpDGKbRD7w")

# Download the file
download_location <- file$download("./my-downloads")
f <- read_file(download_location)

# Read the image file
file_content_bytes = file$read()

# Stream a file
data <- file$stream(function(x) {
  print(length(x))
})

# We can also work with text file data, e.g.:
file <- redivis::file("4c10-bk27tqmet.rkgXgUlmnJrEFFC6oWAqqA")
file_content_string <- file$read(as_text=TRUE)

Load all files in a table

library(redivis)

table <- redivis::organization("Demo")$dataset("example_data_files")$table("example_file_types")

# Download all files
table$download_files("./table_files/")

files = table$list_files()

# Read file contents into memory (don't do this for very large files!)
for (file in files){
    file_content_bytes = file.read()
    # do something...
}

Last updated