From a9ce9c5863f6e59a1cfe2589fdfb0aba9df17eb9 Mon Sep 17 00:00:00 2001 From: meliurwen Date: Wed, 2 Dec 2020 13:54:55 +0100 Subject: [PATCH] Added converter script --- iperf_json2csv.py | 35 +++++++++++++++++++++++++++++++++++ reports/.placeholder | 0 2 files changed, 35 insertions(+) create mode 100755 iperf_json2csv.py create mode 100644 reports/.placeholder diff --git a/iperf_json2csv.py b/iperf_json2csv.py new file mode 100755 index 0000000..0af0fd6 --- /dev/null +++ b/iperf_json2csv.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import json +import sys +import argparse + +def main(arguments): + + with open(arguments.source[0], 'r') as myfile: + iperf_dict = json.loads(myfile.read()) + + keys = "" + for key, value in iperf_dict["intervals"][0]["sum"].items(): + keys = keys + "," + str(key) + print(keys[1:]) + for interval in iperf_dict["intervals"]: + values = "" + for key, value in interval["sum"].items(): + values = values + "," + str(value) + print(values[1:]) + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + prog='iperf json2csv', + usage='%(prog)s -s SOURCE [-h] [--version]', + description='Converts json genereated from iperf into csv.' + ) + parser.add_argument( + "-s", "--source", + nargs=1, + required=True, + help="source where getting the json" + ) + args = parser.parse_args() + main(args) diff --git a/reports/.placeholder b/reports/.placeholder new file mode 100644 index 0000000..e69de29