123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import pandas as pd
- import json
- import os
- directory = os.path.dirname(os.path.abspath(__file__))
- df = pd.read_csv(directory + "/metrics.csv", delimiter=";")
- df = df.dropna(subset=["Metrik"]).reset_index(drop=True)
- catLookUp = {
- "F": "Funktionen",
- "B": "Benutzerfreundlichkeit",
- "P": "Performance",
- "D": "Dokumentation",
- "I": "Installation"
- }
- metrics = []
- category = ""
- df = df.fillna("")
- for i, row in df.iterrows():
- newCat = catLookUp.get(row.get("Nr")[0])
- if type(newCat) == str:
- category = newCat
- rating = {
- "pigeon": row.get("Pigeon"),
- "leaflet": row.get("Leaflet"),
- "mapgl": row.get("MapGL"),
- "mapbox": row.get("Mapbox"),
- "google": row.get("Google"),
- }
- comments = {
- "pigeon": row.get("Kommentar Pigeon"),
- "leaflet": row.get("Kommentar Leaflet"),
- "mapgl": row.get("Kommentar MapGL"),
- "mapbox": row.get("Kommentar Mapbox"),
- "google": row.get("Kommentar Google"),
- }
- metrics.append({
- "metric": row.get("Metrik"),
- "number": row.get("Nr"),
- "category": category,
- "rating": rating,
- "comments": comments
- })
- with open(directory + "/metrics.json", "w") as jsonFile:
- json.dump({"metrics": metrics}, jsonFile, indent=2)
|