diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-06-03 14:42:26 +0200 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-06-03 14:42:26 +0200 |
| commit | feeab5ac8a8d1bb925257f37b9a3af965ce9439d (patch) | |
| tree | 90bf3c3deaa38fed777114b2d940eec12c327e91 /classification/tools | |
| parent | d760c82f4244dc47f5413c3c88b640bb1f0f2d9e (diff) | |
| download | emulator-bug-study-feeab5ac8a8d1bb925257f37b9a3af965ce9439d.tar.gz emulator-bug-study-feeab5ac8a8d1bb925257f37b9a3af965ce9439d.zip | |
tool: results_to_csv parser
Diffstat (limited to 'classification/tools')
| -rwxr-xr-x | classification/tools/parse_categories.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/classification/tools/parse_categories.py b/classification/tools/parse_categories.py new file mode 100755 index 00000000..c57c45e6 --- /dev/null +++ b/classification/tools/parse_categories.py @@ -0,0 +1,29 @@ +from os import listdir, path + +root_directory = "../../results/classifier/" + +def parse_iteration(directory): + dictionary = {} + + for entry in listdir(directory): + full_path = path.join(directory, entry) + if path.isdir(full_path): + dictionary[entry] = len([name for name in listdir(full_path)]) + + return dictionary + +def output_csv(dictionary, full_path): + with open(path.join(full_path, 'categories.csv'), "w") as file: + file.write("category, count\n") + for key, value in dictionary.items(): + file.write(f"{key}, {value}\n") + +def main(): + for entry in listdir(root_directory): + full_path = path.join(root_directory, entry) + if path.isdir(full_path): + dictionary = parse_iteration(full_path) + output_csv(dictionary, full_path) + +if __name__ == "__main__": + main() |