Skip to content

Commit cff6628

Browse files
authored
Merge pull request #48 from bpjelley/master
fixed length str attrs
2 parents afac954 + cf312fc commit cff6628

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pointCollection/data.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ def to_h5(self, fileOut=None,
885885
for key, val in meta_dict[out_field].items():
886886
if key.lower() not in ['group','source_field','precision','dimensions']:
887887
if isinstance(val, str):
888-
h5f_out[out_field_name.encode('ASCII')].attrs[key] = str(val).encode('utf-8')
888+
# h5f_out[out_field_name.encode('ASCII')].attrs[key] = str(val).encode('utf-8')
889+
h5f_out[out_field_name.encode('ASCII')].attrs.create(str(key), str(val).encode('utf-8'), None, dtype='<S'+str(len(str(val))))
889890
else:
890891
h5f_out[out_field_name.encode('ASCII')].attrs[key] = val
891892
if 'dimensions' in meta_dict[out_field]:
@@ -914,7 +915,10 @@ def to_h5(self, fileOut=None,
914915

915916
for key, val in self.attrs.items():
916917
if val is not None:
917-
h5f_out[group].attrs[key]=val
918+
if isinstance(val, str):
919+
h5f_out[out_field_name.encode('ASCII')].attrs.create(str(key), str(val).encode('utf-8'), None, dtype='<S'+str(len(str(val))))
920+
else:
921+
h5f_out[group].attrs[key]=val
918922

919923
for key in ['EPSG','SRS_proj4']:
920924
val=getattr(self, key)

0 commit comments

Comments
 (0)