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()