Skip to content
Snippets Groups Projects
Commit 258472d3 authored by Christoph von Oy's avatar Christoph von Oy
Browse files

Models are jsons now

parent aa20fe54
No related branches found
No related tags found
No related merge requests found
Subproject commit e666cdf7915a24c5fa750649a13dedb3f61f4fdb Subproject commit 933cbeb8de5715ad18184c67a609ce852d152ade
...@@ -23,7 +23,7 @@ THE SOFTWARE. ...@@ -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 import os.path
...@@ -120,3 +120,26 @@ for directory in changed_topologies: ...@@ -120,3 +120,26 @@ for directory in changed_topologies:
print(f"Modified topology {directory}!") print(f"Modified topology {directory}!")
for file in invalid_topologies: for file in invalid_topologies:
print(f"Topology {file} breaks some part of the input file specification!") 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!")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment