diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-03-08 10:52:59 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-03-08 10:52:59 +0100 |
commit | f14522292b4952456dbcf7aeaa2d33b78dc3c953 (patch) | |
tree | f2fd606fe1ca98b709544ebba0e81c53ef75fe73 /lib | |
parent | b09b01fe74eeb446fb14f4449f927cf6130cf1db (diff) |
Add CSV support; right now hard-coded for kaggle acher linux-kernel-size
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/utils.py b/lib/utils.py index af705b9..61cb6f1 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -33,6 +33,31 @@ class NpEncoder(json.JSONEncoder): return super(NpEncoder, self).default(obj) +class CSVfile: + def __init__(self): + pass + + def load(self, f): + observations = list() + for lineno, line in enumerate(f): + if lineno == 0: + param_names = line.split(",")[1:-1] + attr_names = line.removesuffix("\n").split(",")[-1:] + else: + param_values = list(map(soft_cast_int, line.split(",")[1:-1])) + attr_values = list( + map(soft_cast_float, line.removesuffix("\n").split(",")[-1:]) + ) + observations.append( + { + "name": "CSVFile", + "param": dict(zip(param_names, param_values)), + "attribute": dict(zip(attr_names, attr_values)), + } + ) + return observations + + class Logfile: def __init__(self): pass |