Fix bug instruments/readers/structured_file_reader.py. pd.to_dict return a list of dicts so we need to handle each item seprately using a loop.
This commit is contained in:
@ -53,20 +53,22 @@ def read_structured_file_as_dict(path_to_file):
|
|||||||
logging.error("Failed to normalize data structure: %s", exc)
|
logging.error("Failed to normalize data structure: %s", exc)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
for item_idx, item in enumerate(df.to_dict(orient='records')):
|
||||||
structured_array = utils.convert_attrdict_to_np_structured_array(df.to_dict(orient='records'))
|
try:
|
||||||
except Exception as exc:
|
structured_array = utils.convert_attrdict_to_np_structured_array(item)
|
||||||
logging.error("Failed to convert to structured array: %s", exc)
|
except Exception as exc:
|
||||||
raise
|
logging.error("Failed to convert to structured array: %s", exc)
|
||||||
|
raise
|
||||||
|
|
||||||
dataset = {
|
dataset = {
|
||||||
'name': 'data_table',
|
'name': f'data_table_{item_idx}',
|
||||||
'data': structured_array,
|
'data': structured_array,
|
||||||
'shape': structured_array.shape,
|
'shape': structured_array.shape,
|
||||||
'dtype': type(structured_array)
|
'dtype': type(structured_array)
|
||||||
}
|
}
|
||||||
|
|
||||||
file_dict['datasets'].append(dataset)
|
file_dict['datasets'].append(dataset)
|
||||||
|
|
||||||
return file_dict
|
return file_dict
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user