-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
open_mfdataset
does not handle single pathlib.Path
objects but handles single str
just fine
#5881
Labels
Comments
Hi @pmav99, thanks for raising this! I would probably just fix it with diff --git a/xarray/backends/api.py b/xarray/backends/api.py
index 6d73946b..00619d68 100644
--- a/xarray/backends/api.py
+++ b/xarray/backends/api.py
@@ -865,6 +865,8 @@ def open_mfdataset(
)
else:
paths = sorted(glob(_normalize_path(paths)))
+ elif isinstance(paths, Path):
+ paths = [str(paths)]
else:
paths = [str(p) if isinstance(p, Path) else p for p in paths] to emulate the list comprehension we already have. Would you be interested in submitting this little fix as a PR? Or would you rather I did it? |
In fact in light of #5879, it should probably be + elif isinstance(paths, os.PathLike):
+ paths = [str(paths)] instead. |
pmav99
added a commit
to pmav99/xarray
that referenced
this issue
Oct 22, 2021
5 tasks
pmav99
added a commit
to pmav99/xarray
that referenced
this issue
Oct 22, 2021
TomNicholas
pushed a commit
that referenced
this issue
Oct 26, 2021
* Handle single `PathLike` objects in `open_mfdataset()` Fixes #5881 * Update doc/whats-new.rst Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
snowman2
pushed a commit
to snowman2/xarray
that referenced
this issue
Feb 9, 2022
* Handle single `PathLike` objects in `open_mfdataset()` Fixes pydata#5881 * Update doc/whats-new.rst Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened:
An exception was raised
What you expected to happen:
That a dataset object would be created.
Minimal Complete Verifiable Example:
with the following traceback
Anything else we need to know?:
This seems to be fixing it, but I am not familiar with the codebase to know if this is the proper way to fix it
Environment:
Output of xr.show_versions()
The text was updated successfully, but these errors were encountered: