File size: 2,402 Bytes
a42f7fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
70
71
72
73
74
75
76
import streamlit as st
import pandas as pd

# JSON-Dateien laden
def load_city_data(city):
    file_path = f"{city.lower()}.json"
    return pd.read_json(file_path)

# Streamlit-App
def main():
    st.title("Stadt-Daten-Ansicht")

    # Sidebar mit Buttons
    with st.sidebar:
        st.header("Wähle eine Stadt")
        bamberg = st.button("Bamberg")
        coburg = st.button("Coburg")
        bad_kissingen = st.button("Bad Kissingen")

    # Daten laden und anzeigen basierend auf dem geklickten Button
    if bamberg:
        data = load_city_data("Bamberg")
        st.subheader("Daten für Bamberg")

        # Tabelle und Download-Button nebeneinander anordnen
        col1, col2 = st.columns(2)
        with col1:
            st.dataframe(data)
        with col2:
            # Excel-Datei generieren
            excel_data = data.to_excel(index=False)
            st.download_button(
                label="Download Excel",
                data=excel_data,
                file_name="bamberg_data.xlsx",
                mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            )

    if coburg:
        data = load_city_data("Coburg")
        st.subheader("Daten für Coburg")

        # Tabelle und Download-Button nebeneinander anordnen
        col1, col2 = st.columns(2)
        with col1:
            st.dataframe(data)
        with col2:
            # Excel-Datei generieren
            excel_data = data.to_excel(index=False)
            st.download_button(
                label="Download Excel",
                data=excel_data,
                file_name="coburg_data.xlsx",
                mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            )

    if bad_kissingen:
        data = load_city_data("Bad Kissingen")
        st.subheader("Daten für Bad Kissingen")

        # Tabelle und Download-Button nebeneinander anordnen
        col1, col2 = st.columns(2)
        with col1:
            st.dataframe(data)
        with col2:
            # Excel-Datei generieren
            excel_data = data.to_excel(index=False)
            st.download_button(
                label="Download Excel",
                data=excel_data,
                file_name="bad_kissingen_data.xlsx",
                mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            )

if __name__ == "__main__":
    main()