Open
Description
Is your feature request related to a problem?
When I use netCDF4.Dataset
to open a file whose path contains Chinese characters, I get:
import netCDF4
file = "文件.nc"
ds = netCDF4.Dataset(file)
# FileNotFoundError: [Errno 2] No such file or directory: '文件.nc'
If I specify encoding='gbk'
, it opens correctly:
ds = netCDF4.Dataset(file, encoding='gbk')
However, xarray’s open_dataset
does not support an encoding
argument:
import xarray as xr
file = "文件.nc"
ds = xr.open_dataset(file)
# FileNotFoundError: [Errno 2] No such file or directory: 'E:\\netcdf\\文件.nc'
ds = xr.open_dataset(file, engine='netcdf4', encoding='gbk')
# TypeError: NetCDF4BackendEntrypoint.open_dataset() got an unexpected keyword argument 'encoding'
Related netCDF4 issue comment
(from netCDF4-python#997)
Describe the solution you'd like
I would like xarray to accept an encoding
parameter so that files with Chinese paths open successfully.
Describe alternatives you've considered
No response
Additional context
No response