From 31a6f6fa97fde4e5468dff15d86769f35d9d30aa Mon Sep 17 00:00:00 2001 From: "manuela.richter" <manuela.richter@tu-darmstadt.de> Date: Thu, 5 May 2022 18:43:33 +0200 Subject: [PATCH] start testing json data --- test_data.json | 11 +++++++++++ trial_json.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test_data.json create mode 100644 trial_json.py diff --git a/test_data.json b/test_data.json new file mode 100644 index 0000000..5641270 --- /dev/null +++ b/test_data.json @@ -0,0 +1,11 @@ +{ + "KPI":[ + {"Name": "Attribut_1", + "Unit": "Percentage", + "Value": 43}, + {"Name": "Attribut_2", + "Unit": "Percentage", + "Value": 56 + } + ] +} \ No newline at end of file diff --git a/trial_json.py b/trial_json.py new file mode 100644 index 0000000..d28a695 --- /dev/null +++ b/trial_json.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu May 5 17:27:38 2022 + +@author: Richter + +testfile for operating with json-files + +""" + +import json + +with open("test_data.json","r+") as file: + data = json.load(file) + print(len(data)) + print(type(data)) + +#print(data["Name"]) + +a = data.keys() +print(a) +print(type(a)) + +for i in a: + print(i) + key = data[i] + print(len(key)) + print(type(key)) + for j in key: + attrs = list(j) + print(len(attrs)) + print(type(attrs)) + print(attrs) + print(j) -- GitLab