File size: 1,811 Bytes
289125f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import pandas as pd
from ApiCall import *
from Location import * 
import numpy as np

class Warning: 
    def __init__(self):
        # Ort aus Bot Anfrage 
        #self.ort = ort
        # Warnings DataFrame
        warnings = ApiCall.getData(self)
        warnings.replace('', np.nan, inplace=True)
        warnings = warnings[warnings['Plz'].notna()]
        warnings.to_csv('api.csv', index=True)  
        
    def getPlz(self, ort):
        # Plz von Chat auslesen
        plzChat = Location(ort).getPostalCode()
        #print(plzChat)
        return plzChat
    
    def cleanWarnings(self):
        # Gibt Warnings die Plz haben aus 
        self.warnings.replace('', np.nan, inplace=True)
        warnings = self.warnings[self.warnings['Plz'].notna()]
        
        return warnings
    
    def getWarningOrt(self, ort):
        # Plz aus Ort von Nutzer
        plz2 = self.getPlz(ort)
        plz2 = plz2.iloc[0]['name']
        
        try: 
            plz2 = int(plz2)
        except: 
            fehler = "Keine Warnung gefunden"
            print("Fehler")
            return fehler

        print(type(plz2))
        print(plz2)
        
        # Datafrme mit Warnings erstellen
        data = pd.read_csv('api.csv')
        print(data)

        # Plz in DF suchen
        gesuchte_zeile = data.loc[data['Plz'] == plz2]
        print(gesuchte_zeile)
        print("zeile")
        
        if gesuchte_zeile.empty:
            print("fehler")
            fehler = "Es gibt keine Warnung"
            return fehler
        else:
            wert_als_string = gesuchte_zeile.iloc[0]
            print("in schleife")
            return wert_als_string['Titel']
        
    
## Testing Waring 

# plz = Warning("Rottach-Egern")
# gesuchte_zeile = plz.getWarningOrt()
# print(gesuchte_zeile)