Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# JSON-Dateien laden
|
5 |
+
def load_city_data(city):
|
6 |
+
file_path = f"{city.lower()}.json"
|
7 |
+
return pd.read_json(file_path)
|
8 |
+
|
9 |
+
# Streamlit-App
|
10 |
+
def main():
|
11 |
+
st.title("Stadt-Daten-Ansicht")
|
12 |
+
|
13 |
+
# Sidebar mit Buttons
|
14 |
+
with st.sidebar:
|
15 |
+
st.header("Wähle eine Stadt")
|
16 |
+
bamberg = st.button("Bamberg")
|
17 |
+
coburg = st.button("Coburg")
|
18 |
+
bad_kissingen = st.button("Bad Kissingen")
|
19 |
+
|
20 |
+
# Daten laden und anzeigen basierend auf dem geklickten Button
|
21 |
+
if bamberg:
|
22 |
+
data = load_city_data("Bamberg")
|
23 |
+
st.subheader("Daten für Bamberg")
|
24 |
+
|
25 |
+
# Tabelle und Download-Button nebeneinander anordnen
|
26 |
+
col1, col2 = st.columns(2)
|
27 |
+
with col1:
|
28 |
+
st.dataframe(data)
|
29 |
+
with col2:
|
30 |
+
# Excel-Datei generieren
|
31 |
+
excel_data = data.to_excel(index=False)
|
32 |
+
st.download_button(
|
33 |
+
label="Download Excel",
|
34 |
+
data=excel_data,
|
35 |
+
file_name="bamberg_data.xlsx",
|
36 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
37 |
+
)
|
38 |
+
|
39 |
+
if coburg:
|
40 |
+
data = load_city_data("Coburg")
|
41 |
+
st.subheader("Daten für Coburg")
|
42 |
+
|
43 |
+
# Tabelle und Download-Button nebeneinander anordnen
|
44 |
+
col1, col2 = st.columns(2)
|
45 |
+
with col1:
|
46 |
+
st.dataframe(data)
|
47 |
+
with col2:
|
48 |
+
# Excel-Datei generieren
|
49 |
+
excel_data = data.to_excel(index=False)
|
50 |
+
st.download_button(
|
51 |
+
label="Download Excel",
|
52 |
+
data=excel_data,
|
53 |
+
file_name="coburg_data.xlsx",
|
54 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
55 |
+
)
|
56 |
+
|
57 |
+
if bad_kissingen:
|
58 |
+
data = load_city_data("Bad Kissingen")
|
59 |
+
st.subheader("Daten für Bad Kissingen")
|
60 |
+
|
61 |
+
# Tabelle und Download-Button nebeneinander anordnen
|
62 |
+
col1, col2 = st.columns(2)
|
63 |
+
with col1:
|
64 |
+
st.dataframe(data)
|
65 |
+
with col2:
|
66 |
+
# Excel-Datei generieren
|
67 |
+
excel_data = data.to_excel(index=False)
|
68 |
+
st.download_button(
|
69 |
+
label="Download Excel",
|
70 |
+
data=excel_data,
|
71 |
+
file_name="bad_kissingen_data.xlsx",
|
72 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
73 |
+
)
|
74 |
+
|
75 |
+
if __name__ == "__main__":
|
76 |
+
main()
|