-
-
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
' ' at end of variable name causes to_netcdf() to crash #8029
Comments
Thanks for the report. According to the netcdf standard:
See: Maybe you could add a quick cleanup script before writing? |
I have done that. I And as in other ticket, how many of these random gotchas are there. At least the error message needs to be better. |
This error is raised by netCDF4, xarray doesn't care about the variable names, they don't even need to be strings. You could open an issue with netCDF4 to improve the error message. I agree that it should at least contain the invalid name and possibly even the violated rule. |
What we could do is raise a better error message (as @headtr1ck says), which ideally would be implemented upstream in netCDF4 but could also be implemented as a check within the corresponding xarray backend, similar to #7953. @28raining if you want to open a pull request to add an error message like #7953 does then I think that would be welcome (others please point out if you see an issue with that). |
I totally agree. In general I would advise against implementing the same checks on xarray side, this just leads to divergent behavior in the future. |
I've opened a PR upstream to at least make the error messages more helpful: Unidata/netcdf4-python#1268. Suggestions welcome on further improvements! |
What happened?
If variable name ends in a ' ' (space) then to_netcdf crashes.
In my opinion
This is related to #7943
Our tool converts csv files to XARRAY.
So these kind of errors need to self-heal, otherwise we have to feedback to the user and get them to change the csv file.
Which would be frustrating for everyone
What did you expect to happen?
No response
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
No response
Environment
commit : 2e218d10984e9919f0296931d92ea851c6a6faf5
python : 3.11.2.final.0
python-bits : 64
OS : Darwin
OS-release : 22.5.0
Version : Darwin Kernel Version 22.5.0: Thu Jun 8 22:21:34 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T8112
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.3
numpy : 1.24.2
pytz : 2023.3
dateutil : 2.8.2
setuptools : 65.6.3
pip : 23.1.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2023.3.0
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : 2023.2.0
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: