Download a file
This recipe downloads a file from a Unity Catalog volume using the Databricks SDK for Python.
Code snippet
app.py
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
download_file_path = "/Volumes/catalog/schema/volume_name/file.csv"
response = w.files.download(download_file_path)
file_data = response.contents.read()
file_name = os.path.basename(download_file_path)
Resources
Permissions
Your app service principal needs the following permissions:
USE CATALOG
on the volume's catalogUSE SCHEMA
on the volume's schemaREAD VOLUME
on the volume
See Privileges required for volume operations for more information.
Dependencies
- Databricks SDK for Python -
databricks-sdk
- Dash -
dash
requirements.txt
databricks-sdk
dash