Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
|
4 |
# JSON-Dateien laden
|
5 |
def load_city_data(city):
|
@@ -8,7 +9,7 @@ def load_city_data(city):
|
|
8 |
|
9 |
# Streamlit-App
|
10 |
def main():
|
11 |
-
st.title("
|
12 |
|
13 |
# Sidebar mit Buttons
|
14 |
with st.sidebar:
|
@@ -35,13 +36,15 @@ def main():
|
|
35 |
# Tabelle und Download-Button nebeneinander anordnen
|
36 |
col1, col2 = st.columns([3, 1])
|
37 |
with col1:
|
38 |
-
st.dataframe(data, width=
|
39 |
with col2:
|
40 |
# Excel-Datei generieren
|
41 |
-
|
|
|
|
|
42 |
st.download_button(
|
43 |
label="Download Excel",
|
44 |
-
data=
|
45 |
file_name="data.xlsx",
|
46 |
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
47 |
)
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import io # Importieren von io für BytesIO
|
4 |
|
5 |
# JSON-Dateien laden
|
6 |
def load_city_data(city):
|
|
|
9 |
|
10 |
# Streamlit-App
|
11 |
def main():
|
12 |
+
st.title("Stadt-Daten-Ansicht")
|
13 |
|
14 |
# Sidebar mit Buttons
|
15 |
with st.sidebar:
|
|
|
36 |
# Tabelle und Download-Button nebeneinander anordnen
|
37 |
col1, col2 = st.columns([3, 1])
|
38 |
with col1:
|
39 |
+
st.dataframe(data, width=1000)
|
40 |
with col2:
|
41 |
# Excel-Datei generieren
|
42 |
+
excel_buffer = io.BytesIO() # Erstellen eines BytesIO-Objekts
|
43 |
+
data.to_excel(excel_buffer, index=False) # Daten in das BytesIO-Objekt schreiben
|
44 |
+
excel_buffer.seek(0) # Zurücksetzen des Zeigers auf den Anfang des Buffers
|
45 |
st.download_button(
|
46 |
label="Download Excel",
|
47 |
+
data=excel_buffer,
|
48 |
file_name="data.xlsx",
|
49 |
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
50 |
)
|