Refactored list to array conversion using metadata_rewiew_lib
This commit is contained in:
@ -5,7 +5,8 @@ import pandas as pd
|
||||
from igor2.binarywave import load as loadibw
|
||||
|
||||
import src.g5505_utils as utils
|
||||
from src.metadata_review_lib import parse_attribute
|
||||
import src.metadata_review_lib as metadata
|
||||
#from src.metadata_review_lib import parse_attribute
|
||||
|
||||
import yaml
|
||||
import h5py
|
||||
@ -174,13 +175,8 @@ def read_txt_files_as_dict(filename : str ):
|
||||
# https://docs.h5py.org/en/stable/strings.html
|
||||
|
||||
if table_preamble:
|
||||
max_length = max(len(item) for item in table_preamble)
|
||||
# Convert the strings to bytes with utf-8 encoding, specifying errors='ignore' to skip characters that cannot be encoded
|
||||
table_preamble_bytes = [item.encode('utf-8', errors='ignore') for item in table_preamble]
|
||||
|
||||
|
||||
utf8_type = h5py.string_dtype('utf-8', max_length)
|
||||
header_dict["table_preamble"] = np.array(table_preamble_bytes,dtype=utf8_type)
|
||||
header_dict["table_preamble"] = metadata.convert_string_to_bytes(table_preamble)
|
||||
|
||||
|
||||
|
||||
# TODO: it does not work with separator as none :(. fix for RGA
|
||||
@ -238,7 +234,7 @@ def read_txt_files_as_dict(filename : str ):
|
||||
if not key in numerical_variables:
|
||||
dataset['attributes'].pop(key) # delete key
|
||||
else:
|
||||
dataset['attributes'][key] = parse_attribute(dataset['attributes'][key])
|
||||
dataset['attributes'][key] = metadata.parse_attribute(dataset['attributes'][key])
|
||||
except ValueError as err:
|
||||
print(err)
|
||||
|
||||
|
Reference in New Issue
Block a user