From d9fd3a8e2b1530a3735ad20ce771886e965506d0 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Wed, 14 Dec 2022 11:51:53 +0100 Subject: [PATCH] refactoring --- src/IOUtils.py | 7 +++++ src/intensivstationen/Intensivstationen.ipynb | 26 +------------------ 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/IOUtils.py b/src/IOUtils.py index 52d9176f6b8..8948c24dd1f 100644 --- a/src/IOUtils.py +++ b/src/IOUtils.py @@ -1,4 +1,5 @@ import os +import json class IOUtils: @@ -32,6 +33,12 @@ class IOUtils: orient = "split", index = False) + @staticmethod + def saveDictAsJson(dict, file): + IOUtils.ensurePath(file) + with open(file, 'w') as outfile: + json.dump(dict, outfile) + @staticmethod def ensurePath(file): directory = os.path.dirname(file) diff --git a/src/intensivstationen/Intensivstationen.ipynb b/src/intensivstationen/Intensivstationen.ipynb index 97829613547..66036d61eee 100644 --- a/src/intensivstationen/Intensivstationen.ipynb +++ b/src/intensivstationen/Intensivstationen.ipynb @@ -30,6 +30,7 @@ "from ColumnsAdder import ColumnsAdder\n", "from KreisOptionsSetter import KreisOptionsSetter\n", "from TestHelper import TestHelper\n", + "from IOUtils import IOUtils\n", "\n", "pd.set_option('display.max_rows', 100)\n", "pd.set_option('display.max_columns', None)\n", @@ -253,31 +254,6 @@ "saveKreisOptions(kreisOptions)" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "43c2f826", - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import json\n", - "\n", - "\n", - "class IOUtils:\n", - "\n", - " def saveDictAsJson(dict, file):\n", - " IOUtils.ensurePath(file)\n", - " with open(file, 'w') as outfile:\n", - " json.dump(dict, outfile)\n", - "\n", - " @staticmethod\n", - " def ensurePath(file):\n", - " directory = os.path.dirname(file)\n", - " if not os.path.exists(directory):\n", - " os.makedirs(directory)\n" - ] - }, { "cell_type": "code", "execution_count": null,