-
Notifications
You must be signed in to change notification settings - Fork 271
Closed
Description
Currently, it uses nc_put_att_text, which means that the resulting attributes are always saved as bytes in the underlying HDF5 files.
This works OK as long as you only read netCDF4 files back with netCDF4-python (netCDF4-python will automatically convert bytes attributes on Python 3 into str).
But the resulting files are unlikely to be portable. For example, h5py reads such attributes back as bytes:
Python 3.4.3 |Continuum Analytics, Inc.| (default, Mar 6 2015, 12:07:41)
Type "copyright", "credits" or "license" for more information.
IPython 3.1.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import netCDF4
In [2]: ds = netCDF4.Dataset('unicode-str-test.nc', 'w')
In [3]: ds.foo = 'bar'
In [4]: ds.close()
In [5]: import h5py
In [6]: f = h5py.File('unicode-str-test.nc', 'r')
In [7]: f.attrs['foo']
Out[7]: b'bar'
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels