Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
squad-download-attachments: save to a csv file
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Roxell <[email protected]>
  • Loading branch information
roxell committed Dec 21, 2023
1 parent 6ec4fbe commit 8d57e53
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions squad-download-attachments
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
# SPDX-License-Identifier: MIT

import argparse
import csv
import json
import logging
from os import chdir
from pathlib import Path
import statistics
import sys
from squad_client.core.api import SquadApi
from squad_client.core.models import ALL, Squad, TestRun, Environment
Expand Down Expand Up @@ -109,6 +111,30 @@ def run():
with open(file_write, mode="w") as write_file:
write_file.write(pjson)

with open(file_write.replace(".json", ".csv"), mode="w") as csv_file:
csv_writer = csv.writer(csv_file)
dict_json = json.loads(pjson)
if not dict_json["results"]:
continue
headers = ["median", "mean", "standard diviation", "name", "iteration", "name_iteration", "raw data..."]
csv_writer.writerow(headers)
for key in dict_json["results"]["_ResultData"]:
iterations = 0
for k in dict_json["results"]["_ResultData"][key]:
csv_data = []
float_arr = []
for number in k["Values"]:
float_arr.append(float(number))
csv_data.append(statistics.median(float_arr))
csv_data.append(statistics.mean(float_arr))
csv_data.append(statistics.stdev(float_arr))
csv_data.append(key)
iterations = iterations + 1
csv_data.append(f"iteration_{iterations}")
csv_data.append(f"{key}_iterattion_{iterations}")
csv_data.extend(k['Values'])
csv_writer.writerow(csv_data)


if __name__ == "__main__":
sys.exit(run())

0 comments on commit 8d57e53

Please sign in to comment.