File size: 2,800 Bytes
a42f7fa a940780 a42f7fa d36f743 6a95524 ca984f0 6c7781f eefc686 ca984f0 eefc686 d36f743 eefc686 ca984f0 d36f743 ca984f0 6c7781f |
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 77 78 79 80 81 82 83 84 85 86 87 88 89 |
import streamlit as st
import pandas as pd
import io # Importieren von io für BytesIO
# Set page configuration with dark theme
st.set_page_config(
layout="wide",
theme="dark",
initial_sidebar_state="expanded"
)
# JSON-Dateien laden
def load_city_data(city):
file_path = f"{city.lower()}.json"
return pd.read_json(file_path)
# Streamlit-App
def main():
# Sidebar mit Buttons
with st.sidebar:
st.header("Bereich wählen")
# Container für die Buttons
with st.container():
# Breite der Buttons anpassen
st.markdown(
"""
<style>
.stButton > button {
width: 100%;
padding: 10px;
margin: 5px 0;
text-align: center;
}
</style>
""",
unsafe_allow_html=True
)
# Buttons nebeneinander anordnen
bamberg = st.button("Bamberg")
coburg = st.button("Coburg")
bad_kissingen = st.button("Bad Kissingen")
kronach = st.button("Kronach")
forchheim = st.button("Forchheim")
# Daten laden und anzeigen basierend auf dem geklickten Button
data = None
if bamberg:
data = load_city_data("Bamberg")
if coburg:
data = load_city_data("Coburg")
if bad_kissingen:
data = load_city_data("Kissingen")
if data is not None:
# Container für die Überschrift und den Download-Button
header_container = st.container()
with header_container:
# Überschrift und Download-Button nebeneinander
col1, col2 = st.columns([4, 1])
with col1:
if bamberg:
st.subheader("Vereine in Bamberg")
elif coburg:
st.subheader("Vereine in Coburg")
elif bad_kissingen:
st.subheader("Vereine in Bad Kissingen")
elif kronach:
st.subheader("Vereine in Kronach")
elif forchheim:
st.subheader("Vereine in Forchheim")
with col2:
# Excel-Datei generieren
excel_buffer = io.BytesIO()
data.to_excel(excel_buffer, index=False)
excel_buffer.seek(0)
st.download_button(
label="Download Excel",
data=excel_buffer,
file_name="data.xlsx",
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
)
# Tabelle unterhalb der Überschrift
st.dataframe(data, width=1500)
if __name__ == "__main__":
main() |