File
class File
Constructors
Examples
f = redivis.file("4c10-d8rqhswh8.zz7AB9NJB2ctNpDGKbRD7w")
download_path = f.download("./my-downloads")
with open (download_path, "r") as f:
# Do stuff with the file!f = redivis.file("4c10-bk27tqmet.rkgXgUlmnJrEFFC6oWAqqA")
# set as_text to False to read as Bytes
file_content_string = f.read(as_text=True)from io import TextIOWrapper
f = redivis.file("rnwk-acs3famee.pVr4Gzq54L3S9pblMZTs5Q")
with f.stream() as f_stream:
f_stream.read(100) # read 100 bytes
with TextIOWrapper(f.stream()) as f_stream:
f_stream.readline() # read first line
# We can use streams to work with files similarly
# to if they were on disk, e.g.:
from PIL import Image
# References the file bogota.tiff at https://redivis.com/datasets/yz1s-d09009dbb/files/4c10-d8rqhswh8.zz7AB9NJB2ctNpDGKbRD7w
file = redivis.file("4c10-d8rqhswh8.zz7AB9NJB2ctNpDGKbRD7w")
# Pass the file as a bytesIO stream to PIL to load as an image
print(Image.open(file.stream()))
Attributes
Methods
Was this helpful?

