Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
-
|
| 4 |
-
###################################
|
| 5 |
from st_aggrid import AgGrid
|
| 6 |
from st_aggrid.grid_options_builder import GridOptionsBuilder
|
| 7 |
from st_aggrid.shared import JsCode
|
| 8 |
-
|
| 9 |
-
###################################
|
| 10 |
-
|
| 11 |
from download import download_button
|
| 12 |
-
|
| 13 |
-
###################################
|
| 14 |
-
|
| 15 |
|
| 16 |
def _max_width_():
|
| 17 |
max_width_str = f"max-width: 1800px;"
|
|
@@ -35,47 +28,36 @@ with col2:
|
|
| 35 |
st.title("CSV Dataset Analyzer")
|
| 36 |
with col3:
|
| 37 |
st.write("")
|
| 38 |
-
|
| 39 |
c29, c30, c31 = st.columns([1, 6, 1])
|
| 40 |
-
|
| 41 |
with c30:
|
| 42 |
-
|
| 43 |
uploaded_file = st.file_uploader(
|
| 44 |
"",
|
| 45 |
key="1",
|
| 46 |
help="To activate 'wide mode', go to the hamburger menu > Settings > turn on 'wide mode'",
|
| 47 |
)
|
| 48 |
-
|
| 49 |
if uploaded_file is not None:
|
| 50 |
file_container = st.expander("Check your uploaded .csv")
|
| 51 |
shows = pd.read_csv(uploaded_file)
|
| 52 |
uploaded_file.seek(0)
|
| 53 |
file_container.write(shows)
|
| 54 |
-
|
| 55 |
else:
|
| 56 |
st.info(
|
| 57 |
f"""
|
| 58 |
👆 Upload a .csv file first. Sample to try: [biostats.csv](https://people.sc.fsu.edu/~jburkardt/data/csv/biostats.csv)
|
| 59 |
"""
|
| 60 |
)
|
| 61 |
-
|
| 62 |
st.stop()
|
| 63 |
-
|
| 64 |
-
from st_aggrid import GridUpdateMode, DataReturnMode
|
| 65 |
-
|
| 66 |
gb = GridOptionsBuilder.from_dataframe(shows)
|
| 67 |
-
# enables pivoting on all columns, however i'd need to change ag grid to allow export of pivoted/grouped data, however it select/filters groups
|
| 68 |
gb.configure_default_column(enablePivot=True, enableValue=True, enableRowGroup=True)
|
| 69 |
gb.configure_selection(selection_mode="multiple", use_checkbox=True)
|
| 70 |
gb.configure_side_bar() # side_bar is clearly a typo :) should by sidebar
|
| 71 |
gridOptions = gb.build()
|
| 72 |
-
|
| 73 |
st.success(
|
| 74 |
f"""
|
| 75 |
💡 Tip! Hold the shift key when selecting rows to select multiple rows at once!
|
| 76 |
"""
|
| 77 |
)
|
| 78 |
-
|
| 79 |
response = AgGrid(
|
| 80 |
shows,
|
| 81 |
gridOptions=gridOptions,
|
|
@@ -84,26 +66,18 @@ response = AgGrid(
|
|
| 84 |
data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
|
| 85 |
fit_columns_on_grid_load=False,
|
| 86 |
)
|
| 87 |
-
|
| 88 |
df = pd.DataFrame(response["selected_rows"])
|
| 89 |
-
|
| 90 |
st.subheader("Filtered data will appear below 👇 ")
|
| 91 |
st.text("")
|
| 92 |
-
|
| 93 |
st.table(df)
|
| 94 |
-
|
| 95 |
st.text("")
|
| 96 |
-
|
| 97 |
c29, c30, c31 = st.columns([1, 1, 2])
|
| 98 |
-
|
| 99 |
with c29:
|
| 100 |
-
|
| 101 |
CSVButton = download_button(
|
| 102 |
df,
|
| 103 |
"File.csv",
|
| 104 |
"Download to CSV",
|
| 105 |
)
|
| 106 |
-
|
| 107 |
with c30:
|
| 108 |
CSVButton = download_button(
|
| 109 |
df,
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
|
|
|
| 3 |
from st_aggrid import AgGrid
|
| 4 |
from st_aggrid.grid_options_builder import GridOptionsBuilder
|
| 5 |
from st_aggrid.shared import JsCode
|
|
|
|
|
|
|
|
|
|
| 6 |
from download import download_button
|
| 7 |
+
from st_aggrid import GridUpdateMode, DataReturnMode
|
|
|
|
|
|
|
| 8 |
|
| 9 |
def _max_width_():
|
| 10 |
max_width_str = f"max-width: 1800px;"
|
|
|
|
| 28 |
st.title("CSV Dataset Analyzer")
|
| 29 |
with col3:
|
| 30 |
st.write("")
|
|
|
|
| 31 |
c29, c30, c31 = st.columns([1, 6, 1])
|
|
|
|
| 32 |
with c30:
|
|
|
|
| 33 |
uploaded_file = st.file_uploader(
|
| 34 |
"",
|
| 35 |
key="1",
|
| 36 |
help="To activate 'wide mode', go to the hamburger menu > Settings > turn on 'wide mode'",
|
| 37 |
)
|
|
|
|
| 38 |
if uploaded_file is not None:
|
| 39 |
file_container = st.expander("Check your uploaded .csv")
|
| 40 |
shows = pd.read_csv(uploaded_file)
|
| 41 |
uploaded_file.seek(0)
|
| 42 |
file_container.write(shows)
|
|
|
|
| 43 |
else:
|
| 44 |
st.info(
|
| 45 |
f"""
|
| 46 |
👆 Upload a .csv file first. Sample to try: [biostats.csv](https://people.sc.fsu.edu/~jburkardt/data/csv/biostats.csv)
|
| 47 |
"""
|
| 48 |
)
|
|
|
|
| 49 |
st.stop()
|
| 50 |
+
|
|
|
|
|
|
|
| 51 |
gb = GridOptionsBuilder.from_dataframe(shows)
|
|
|
|
| 52 |
gb.configure_default_column(enablePivot=True, enableValue=True, enableRowGroup=True)
|
| 53 |
gb.configure_selection(selection_mode="multiple", use_checkbox=True)
|
| 54 |
gb.configure_side_bar() # side_bar is clearly a typo :) should by sidebar
|
| 55 |
gridOptions = gb.build()
|
|
|
|
| 56 |
st.success(
|
| 57 |
f"""
|
| 58 |
💡 Tip! Hold the shift key when selecting rows to select multiple rows at once!
|
| 59 |
"""
|
| 60 |
)
|
|
|
|
| 61 |
response = AgGrid(
|
| 62 |
shows,
|
| 63 |
gridOptions=gridOptions,
|
|
|
|
| 66 |
data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
|
| 67 |
fit_columns_on_grid_load=False,
|
| 68 |
)
|
|
|
|
| 69 |
df = pd.DataFrame(response["selected_rows"])
|
|
|
|
| 70 |
st.subheader("Filtered data will appear below 👇 ")
|
| 71 |
st.text("")
|
|
|
|
| 72 |
st.table(df)
|
|
|
|
| 73 |
st.text("")
|
|
|
|
| 74 |
c29, c30, c31 = st.columns([1, 1, 2])
|
|
|
|
| 75 |
with c29:
|
|
|
|
| 76 |
CSVButton = download_button(
|
| 77 |
df,
|
| 78 |
"File.csv",
|
| 79 |
"Download to CSV",
|
| 80 |
)
|
|
|
|
| 81 |
with c30:
|
| 82 |
CSVButton = download_button(
|
| 83 |
df,
|