-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option recursive to listdir #1275
Comments
@adriantre I'm interested. Can you tell me more about how you would use this? |
Thanks Sean! I started using TorchGeo and found that there were only some minor blockers for it to be able to read files directly from cloud storage through GDAL VSI. The only blocker is they are pattern-matching files using root = "/vsigs/my_bucket'
filename_glob = "T*_B02_10m.tif"
pathname = os.path.join(root, "**", filename_glob)
for filepath in glob.iglob(pathname, recursive=True):
... I don't know how easy it would be to mirror the behaviour of A similar option is Pathlib.rglob. Another approach would be to create a for root, subdirs, files in os.walk(walk_dir):
for file in files:
asb_path_for_file = os.path.join(root, file
#file is filenames only but os.path.join will magically yield the abs path I created a PR to TorchGeo with the above workaround. But I think swapping out the usage of |
@adriantre after some reflection, I'm inclined not to do this. First of all, the workaround isn't terrible, and not adding a new feature to fiona (or rasterio) saves us testing, documentation, &c. But mostly I don't want fiona and rasterio to become cloud storage APIs. GDAL's VSI system has a whole cloud storage API, but I believe Python developers are much better off using their cloud's Python SDK (boto3, for example) or a dedicated cross-cloud library like https://libcloud.apache.org/. |
I understand. Cross-cloud is why I was looking to GDAL/Fiona, to have a platform-agnostic solution. libcloud looks promising. |
Fiona/fiona/ogrext.pyx
Line 1921 in b23fd3b
Would it be a quick fix to use VSIReadDirRecursive in
fiona.listdir
to enable recursive listing within VSI?Current workaround:
Should maybe return file paths relative to root to be consistent with listdir as is. (In my workaround I include root).
The text was updated successfully, but these errors were encountered: