I have found some approaches, but unfortunately none, where it comes to the contents of Dictioranies. I hope this question is not a duplicate.
My Code:
import os
import csv
import glob
os.chdir("/Users/x/PycharmProjects/x")
listme = list()
for csvs in glob.glob("*.csv"):
with open(csvs, mode="r") as csvfile:
csv_reader = csv.DictReader(csvfile)
for row in csv_reader:
spek = {"name": row['name'], "party": row['group'], "term":row['term']}
listme.append(spek)
for element in listme:
print(element)
My Output (about 5000 elements):
{'name': 'Erwin Stahl', 'party': 'SPD', 'term': '9'}
{'name': 'Eugen Glombig', 'party': 'SPD', 'term': '9'}
{'name': 'Eugen von der Wiesche', 'party': 'SPD', 'term': '9'}
{'name': 'Ferdinand Tillmann', 'party': 'CDU', 'term': '9'}
{'name': 'Franz Amrehn', 'party': 'CDU', 'term': '9'}
{'name': 'Franz Handlos', 'party': 'CSU', 'term': '9'}
{'name': 'Franz Heinrich Krey', 'party': 'CDU', 'term': '9'}
{'name': 'Franz Josef Conrad', 'party': 'CDU', 'term': '9'}
How can I now check if in a term, a person of the same name exits from the same party only once? The name and party combination may occur, but not in the same term.
Thank you in advance!