diff --git a/Model_Library b/Model_Library index e666cdf7915a24c5fa750649a13dedb3f61f4fdb..933cbeb8de5715ad18184c67a609ce852d152ade 160000 --- a/Model_Library +++ b/Model_Library @@ -1 +1 @@ -Subproject commit e666cdf7915a24c5fa750649a13dedb3f61f4fdb +Subproject commit 933cbeb8de5715ad18184c67a609ce852d152ade diff --git a/input_files/convert_input_files_new_input_format.py b/input_files/convert_input_files_new_input_format.py index a4d8d37199bd88b118ffc48c37acd94486b46dca..1b48ff4114fd457b2821ed4217ce01ee13611538 100644 --- a/input_files/convert_input_files_new_input_format.py +++ b/input_files/convert_input_files_new_input_format.py @@ -23,7 +23,7 @@ THE SOFTWARE. """ """ -This script inspects the input files and modifies them such that they adhere to the new input file specification used by the framework after merge of merge request !TODO New input format. +This script inspects the input files and modifies them such that they adhere to the new input file specification used by the framework after merge of merge request !24 New input format. """ import os.path @@ -120,3 +120,26 @@ for directory in changed_topologies: print(f"Modified topology {directory}!") for file in invalid_topologies: print(f"Topology {file} breaks some part of the input file specification!") + +changed_models = [] +invalid_models = [] +for dirpath, dirnames, filenames in os.walk(".\\Model_Library\\Component\\data"): + for filename in filenames: + if filename.endswith(".csv"): + try: + print(f"Inspecting model {os.path.join(dirpath, filename)}") + model = pd.read_csv(os.path.join(dirpath, filename)) + model_json = dict() + for i in model.columns: + no_space_name = "_".join(i.split(" ")) + model_json[no_space_name] = model[i][0] + changed_models.append(os.path.join(dirpath, filename)) + os.remove(os.path.join(dirpath, filename)) + with open(os.path.join(dirpath, "".join(filename.split(".")[:-1]) + ".json"), "w", encoding ="utf-8") as f: + json.dump(model_json, f, indent = 4, default = np_encoder) + except: + invalid_models.append(os.path.join(dirpath, filename)) +for directory in changed_models: + print(f"Modified model {directory}!") +for file in invalid_models: + print(f"Model {file} breaks some part of the input file specification!")