diff --git a/parser.py b/parser.py old mode 100644 new mode 100755 index d3709f6..772d43e --- a/parser.py +++ b/parser.py @@ -1,6 +1,9 @@ +#!/usr/bin/python3 import os import csv +import json +result = {} for file in os.listdir("./"): if file.endswith(".csv"): yesVotes = {'CDU/CSU': 0, 'SPD': 0, 'DIE LINKE.': 0, 'BÜ90/GR': 0} @@ -38,9 +41,11 @@ noVotes.update({k: v/votes[k] for k,v in noVotes.items()}) abstVotes.update({k: v/votes[k] for k,v in abstVotes.items()}) invalidVotes.update({k: v/votes[k] for k,v in invalidVotes.items()}) - print("Dafür: ", yesVotes) - print("Dagegen: ", noVotes) - print("Enhalten: ", abstVotes) - print("Ungültig: ", invalidVotes) - print("Nicht abgestimmt: ", notVotes) - print("Stimmen gesamt: ", votes) + result[file[:-4]] = { + 'yes': yesVotes, + 'no': noVotes, + 'abst': abstVotes, + 'inv': invalidVotes, + 'not': notVotes + } +print(json.dumps(result))