|
import streamlit as st |
|
import pandas as pd |
|
import io |
|
|
|
st.set_page_config(layout="wide") |
|
|
|
|
|
def load_city_data(city): |
|
file_path = f"{city.lower()}.json" |
|
return pd.read_json(file_path) |
|
|
|
|
|
def main(): |
|
|
|
|
|
with st.sidebar: |
|
st.header("Bereich wählen") |
|
|
|
with st.container(): |
|
|
|
st.markdown( |
|
""" |
|
<style> |
|
.stButton > button { |
|
width: 100%; |
|
padding: 10px; |
|
margin: 5px 0; |
|
text-align: center; |
|
} |
|
</style> |
|
""", |
|
unsafe_allow_html=True |
|
) |
|
|
|
bamberg = st.button("Bamberg") |
|
coburg = st.button("Coburg") |
|
bad_kissingen = st.button("Bad Kissingen") |
|
kronach = st.button("Kronach") |
|
forchheim = st.button("Forchheim") |
|
lichtenfels = st.button("Lichtenfels") |
|
hassberge = st.button("Hassberge") |
|
erlangen = st.button("Erlangen") |
|
|
|
|
|
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 kronach: |
|
data = load_city_data("Kronach") |
|
|
|
if forchheim: |
|
data = load_city_data("Forchheim") |
|
|
|
if lichtenfels: |
|
data = load_city_data("Lichtenfels") |
|
|
|
if hassberge: |
|
data = load_city_data("Hassberge") |
|
|
|
if erlangen: |
|
data = load_city_data("Erlangen") |
|
|
|
if data is not None: |
|
|
|
header_container = st.container() |
|
with header_container: |
|
|
|
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") |
|
elif lichtenfels: |
|
st.subheader("Vereine in Lichtenfels") |
|
elif hassberge: |
|
st.subheader("Vereine Hassberge") |
|
elif erlangen: |
|
st.subheader("Vereine in Erlangen") |
|
with col2: |
|
|
|
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" |
|
) |
|
|
|
|
|
st.dataframe(data, width=1500) |
|
|
|
if __name__ == "__main__": |
|
main() |