CSV flexibler auslesen; Schadstoffmobil rausgenommen
This commit is contained in:
parent
6fdbc75104
commit
54367f5289
@ -75,6 +75,7 @@ def read_file(jahr):
|
||||
''' Liest Daten aus muell<jahr>.csv und liefert ggf. Ergebnis zurück'''
|
||||
|
||||
antwort_liste = list()
|
||||
headline = list()
|
||||
try:
|
||||
with open(f'muell{jahr}.csv', 'r', encoding="latin1") as f:
|
||||
csv_reader = csv.reader(f, delimiter=';')
|
||||
@ -83,6 +84,7 @@ def read_file(jahr):
|
||||
for row in csv_reader:
|
||||
if lines == 0:
|
||||
# print(f'Column names are {", ".join(row)}')
|
||||
headline = row
|
||||
lines += 1
|
||||
else:
|
||||
if isinstance(row, list):
|
||||
@ -90,7 +92,7 @@ def read_file(jahr):
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
return antwort_liste
|
||||
return (antwort_liste, headline)
|
||||
|
||||
# Variablen
|
||||
key = 'e21758b9c711463552fb9c70ac7d4273'
|
||||
@ -111,7 +113,7 @@ postdata = {
|
||||
'f_id_abfalltyp_3': '187',
|
||||
'f_id_abfalltyp_4': '169',
|
||||
'f_abfallarten_index_max': '5',
|
||||
'f_abfallarten': '50,161,53,187,169',
|
||||
'f_abfallarten': '50,161,53,187',
|
||||
'f_zeitraum': zeitraum,
|
||||
'f_export_als': export_als,
|
||||
}
|
||||
@ -121,16 +123,8 @@ headers = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
|
||||
muell_arten = [
|
||||
'Gelbe Tonne',
|
||||
'Biomüll',
|
||||
'Papiermüll',
|
||||
'Restmüll',
|
||||
'Schadstoffmobil',
|
||||
]
|
||||
|
||||
if __name__ == '__main__':
|
||||
antwort_liste = read_file(current_year)
|
||||
(antwort_liste, headline) = read_file(current_year)
|
||||
config = readConfig()
|
||||
|
||||
if not antwort_liste:
|
||||
@ -149,7 +143,7 @@ if __name__ == '__main__':
|
||||
f = open(f'muell{current_year}.csv', 'wb')
|
||||
f.write(content)
|
||||
f.close()
|
||||
antwort_liste = read_file(current_year)
|
||||
(antwort_liste, headline) = read_file(current_year)
|
||||
|
||||
tomorrow = (datetime.now() + timedelta(1)).strftime('%d.%m.%Y')
|
||||
index = set();
|
||||
@ -164,7 +158,7 @@ if __name__ == '__main__':
|
||||
wird = 'wird' if len(index) < 2 else 'werden'
|
||||
tonnen = []
|
||||
for pos in index:
|
||||
tonnen.append(muell_arten[pos])
|
||||
tonnen.append(headline[pos])
|
||||
|
||||
if len(tonnen) > 0:
|
||||
tonnen = ' und '.join(tonnen)
|
||||
|
Loading…
Reference in New Issue
Block a user