|
|
|
@ -74,7 +74,7 @@ def init(key, modus, host, headers):
|
|
|
|
|
def read_file(jahr): |
|
|
|
|
''' Liest Daten aus muell<jahr>.csv und liefert ggf. Ergebnis zurück''' |
|
|
|
|
|
|
|
|
|
antwort_liste = None |
|
|
|
|
antwort_liste = list() |
|
|
|
|
try: |
|
|
|
|
with open(f'muell{jahr}.csv', 'r', encoding="latin1") as f: |
|
|
|
|
csv_reader = csv.reader(f, delimiter=';') |
|
|
|
@ -85,8 +85,8 @@ def read_file(jahr):
|
|
|
|
|
# print(f'Column names are {", ".join(row)}') |
|
|
|
|
lines += 1 |
|
|
|
|
else: |
|
|
|
|
if isinstance(row, list): |
|
|
|
|
antwort_liste.extend(row) |
|
|
|
|
if isinstance(row, list): |
|
|
|
|
antwort_liste.append(row) |
|
|
|
|
except FileNotFoundError: |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
@ -122,10 +122,10 @@ headers = {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
muell_arten = [ |
|
|
|
|
'Biomüll', |
|
|
|
|
'Gelbe Tonne', |
|
|
|
|
'Restmüll', |
|
|
|
|
'Biomüll', |
|
|
|
|
'Papiermüll', |
|
|
|
|
'Restmüll', |
|
|
|
|
'Schadstoffmobil', |
|
|
|
|
] |
|
|
|
|
|
|
|
|
@ -151,19 +151,22 @@ if __name__ == '__main__':
|
|
|
|
|
f.close() |
|
|
|
|
antwort_liste = read_file(current_year) |
|
|
|
|
|
|
|
|
|
daten = set(antwort_liste) |
|
|
|
|
tomorrow = (datetime.now() + timedelta(1)).strftime('%d.%m.%Y') |
|
|
|
|
for datum in daten: |
|
|
|
|
datum = datum.split(';') |
|
|
|
|
l_muell = get_index_positions(datum, tomorrow) |
|
|
|
|
if len(l_muell) > 0: |
|
|
|
|
wird = 'wird' if len(l_muell) < 2 else 'werden' |
|
|
|
|
tonnen = [] |
|
|
|
|
for i in l_muell: |
|
|
|
|
tonnen.append(muell_arten[i]) |
|
|
|
|
|
|
|
|
|
if len(tonnen) > 0: |
|
|
|
|
tonnen = ' und '.join(tonnen) |
|
|
|
|
# Jetzt den Bot ansprechen |
|
|
|
|
os.system(f'echo "Morgen {wird} {tonnen} abgeholt" | {config["pathBot"]} -u {config["tgReceiver"]}') |
|
|
|
|
break |
|
|
|
|
index = set(); |
|
|
|
|
for row in antwort_liste: |
|
|
|
|
try: |
|
|
|
|
pos = row.index(tomorrow) |
|
|
|
|
if pos < 4: |
|
|
|
|
index.add(pos) |
|
|
|
|
except ValueError: |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
wird = 'wird' if len(index) < 2 else 'werden' |
|
|
|
|
tonnen = [] |
|
|
|
|
for pos in index: |
|
|
|
|
tonnen.append(muell_arten[pos]) |
|
|
|
|
|
|
|
|
|
if len(tonnen) > 0: |
|
|
|
|
tonnen = ' und '.join(tonnen) |
|
|
|
|
# Jetzt den Bot ansprechen |
|
|
|
|
os.system(f'echo "Morgen {wird} {tonnen} abgeholt" | {config["pathBot"]} -u {config["tgReceiver"]}') |
|
|
|
|