|
import pandas as pd |
|
from pages.ApiCall import * |
|
from pages.Location import * |
|
import numpy as np |
|
|
|
class Warning: |
|
def __init__(self): |
|
|
|
|
|
|
|
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): |
|
|
|
plzChat = Location(ort).getPostalCode() |
|
|
|
return plzChat |
|
|
|
def cleanWarnings(self): |
|
|
|
self.warnings.replace('', np.nan, inplace=True) |
|
warnings = self.warnings[self.warnings['Plz'].notna()] |
|
|
|
return warnings |
|
|
|
def getWarningOrt(self, ort): |
|
|
|
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) |
|
|
|
|
|
data = pd.read_csv('api.csv') |
|
print(data) |
|
|
|
|
|
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'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|