One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
tXiao95
6 years agoNew member | Level 2
How to use the Python SDK to download netcdf files
I have some large netcdf4 files in my personal Dropbox on the order of about 12GB. I'd like to use the Python SDK to read these files directly into my session without having to download them locally but am not sure how to use the Response object that gets returned by files_download()? I work with .nc files primarily with the `xarray` package, so was wondering what the best way to get from the Response object specified by my path to a xarray object would be. The code I currently have is below.
import dropbox import netCDF4 import xarray as xr access_token = XXXXXX dbx = dropbox.Dropbox(access_token) db_path = "/MAXT.nc" metadata, f = dbx.files_download(db_path)
- Greg-DB
Dropbox Staff
The
files_download
method gives you arequests.Response
object that you can read from, optionally in pieces, without downloading the entire file to your local filesystem.For example, you might want to read it a piece at a time, like:
metadata, f = dbx.files_download(path) for partial_data in f.iter_content(chunk_size=1024): print(partial_data) raw_input() # whatever you need to do
I can't offer help with netCDF4 or xarray though, as those are not made by Dropbox.
About Discuss Dropbox Developer & API
Make connections with other developers804 PostsLatest Activity: 14 hours ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!