# Working with non-tabular data

### **Load a single file**

```r
# 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")
```

### Load all files in a table

```r
t <- redivis$table("Demo.example_data_files.example_file_types")

dir <- t.to_directory()
f <- dir.get("path/to/file.txt") # Will return None if doesn't exist
dir$download("/download/path") # Download all files to the provided path
dir$mount("/download/path")
# dir.mount() behaves the same as dir.download() was called (all files appear on disk)
# However, this doesn't actually download the files until they're needed, 
#    and as such is much faster, particularly when all files may not need to be read.
```
