From 596a35f7f134d18f5ee6aa895c834819b4a938a3 Mon Sep 17 00:00:00 2001 From: Florez Ospina Juan Felipe Date: Fri, 18 Aug 2023 11:47:20 +0200 Subject: [PATCH] Modified read_hdf5_as_table.m to read String entries as chars. --- import/read_hdf5_as_table.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/import/read_hdf5_as_table.m b/import/read_hdf5_as_table.m index cd60605..12af873 100644 --- a/import/read_hdf5_as_table.m +++ b/import/read_hdf5_as_table.m @@ -77,7 +77,17 @@ for i = 1 : num_rows end if j > num_attr1 Name = INFO.Groups(i).Attributes(j-num_attr1).Name; - tmp{i,j} = h5readatt(filename,INFO.Groups(i).Name, Name); + Datatype = INFO.Groups(i).Attributes(j-num_attr1).Datatype.Class; + + % Detect string attributes and convert them to characters. + % TODO: extend to other necessary data types. + if strcmp(Datatype,'H5T_STRING') + convert_func = @(x) convertStringsToChars(x); + else % no data type conversion is performed + convert_func = @(x) x; + end + + tmp{i,j} = convert_func(h5readatt(filename,INFO.Groups(i).Name, Name)); if i < 2 disp(Name)