diff --git a/parser.py b/parser.py new file mode 100644 index 0000000..58feee4 --- /dev/null +++ b/parser.py @@ -0,0 +1,36 @@ +import os +import csv + +for file in os.listdir("./"): + if file.endswith(".csv"): + yesVotes = {'CDU/CSU': 0, 'SPD': 0, 'DIE LINKE.': 0, 'BÜ90/GR': 0} + noVotes = {'CDU/CSU': 0, 'SPD': 0, 'DIE LINKE.': 0, 'BÜ90/GR': 0} + abstVotes = {'CDU/CSU': 0, 'SPD': 0, 'DIE LINKE.': 0, 'BÜ90/GR': 0} + invalidVotes = {'CDU/CSU': 0, 'SPD': 0, 'DIE LINKE.': 0, 'BÜ90/GR': 0} + notVotes = {'CDU/CSU': 0, 'SPD': 0, 'DIE LINKE.': 0, 'BÜ90/GR': 0} + #"Wahlperiode","Sitzungnr","Abstimmnr","Fraktion/Gruppe","Name","Vorname","Titel","ja","nein","Enthaltung","ungültig","nichtabgegeben","Bezeichnung" + with open(file, 'r', encoding='utf-8') as csvfile: + csvreader = csv.reader(csvfile, delimiter=',') + firstrow = True + for row in csvreader: + #skip header + if firstrow: + firstrow = False + continue + party = row[3] + if row[7] == "1.0": + yesVotes[party] += 1 + elif row[8] == "1.0": + noVotes[party] += 1 + elif row[9] == "1.0": + abstVotes[party] += 1 + elif row[10] == "1.0": + invalidVotes[party] += 1 + else: + notVotes[party] += 1 + # print ergs + print("Dafür: ", yesVotes) + print("Dagegen: ", noVotes) + print("Enhalten: ", abstVotes) + print("Ungültig: ", invalidVotes) + print("Nicht abgestimmt: ", notVotes)