36 lines
907 B
Python
36 lines
907 B
Python
# -*- coding: ansi -*-
|
|
import csv
|
|
from collections import defaultdict
|
|
|
|
def auswertung(csvf: str):
|
|
try:
|
|
with open(csvf, "r") as f:
|
|
reader = csv.reader(f, delimiter=";")
|
|
|
|
header = next(reader)
|
|
|
|
marken_count = defaultdict(int)
|
|
total_dataset = 0
|
|
|
|
for row in reader:
|
|
if len(row) < 2:
|
|
continue
|
|
|
|
total_dataset += 1
|
|
marke = row[1]
|
|
marken_count[marke] += 1
|
|
|
|
print(f"Insgesamt sind {total_dataset} Datensätze gespeichert!")
|
|
print(f"Insgesamt sind {len(marken_count)} verschiedene Automarken gespeichert!")
|
|
|
|
print()
|
|
|
|
for i, marke in enumerate(sorted(marken_count.keys()), start=1):
|
|
print(f"{i} : {marke} ist {marken_count[marke]} mal in der Liste gespeichert")
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
|
|
|
auswertung("cars.csv")
|