File
class File
Constructors
Examples
import redivis
from io import TextIOWrapper
from PIL import Image
# See https://redivis.com/datasets/yz1s-d09009dbb/files for example data
table = redivis.table("demo.example_data_files:yz1s:v1_3.example_file_types:4c10")
text_file = table.file("pandas_core.py")
image_file = table.file("bogota.tiff"")
## Read file contents
str = text_file.read(as_text=True)
bytes = image_file.read()
## Open the file, as if it was on the filesystem
with file.open() as f:
f.read(100) # read 100 bytes
with TextIOWrapper(file.open()) as f:
f.readline() # read first line
Image.open(table.file("bogota.tiff")) # PIL will automatically call open() on the file
## Download the file
image_file.download("./path") # will be downloaded as ./path/bogota.tiff
text_file.download("./path/renamed.txt") # will be downloaded as ./path/renamed.txtAttributes
Methods
Last updated
Was this helpful?

