Skip to content

add **encoding** argument in netCDF4 backend #10372

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
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wqshen
Copy link

@wqshen wqshen commented May 29, 2025

add encoding argument in netCDF4 backend to support reading NetCDF file with non-ASCII path or filename.

The behavior is consistent with upstream netCDF4 library, default path encoding is set to sys.getdefaultfileencoding() .

…ile with non-ASCII path or filename and keep consistent behavior with upstream netcdf4 library
Copy link

welcome bot commented May 29, 2025

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

@dcherian
Copy link
Contributor

dcherian commented May 29, 2025

Nice, can you add a test here please?

class TestNetCDF4Data(NetCDF4Base):

It can simply roundtrip a simple dataset to a file with a filename that doesn't work today.

@kmuehlbauer
Copy link
Contributor

How is this handled in the light of this comment #9282 (comment) by @dcherian?

@dcherian
Copy link
Contributor

Hah! Probably good to use filename_encoding since we'll probably to support writing files with such file names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support an encoding parameter when reading netCDF files with xarray
3 participants