Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
tXiao95
7 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)
1 Reply
- Greg-DB7 years ago
Dropbox Community Moderator
The
files_downloadmethod gives you arequests.Responseobject 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 doI 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 developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!