Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,8 @@ 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 |
def _max_width_():
|
| 9 |
max_width_str = f"max-width: 1800px;"
|
| 10 |
st.markdown(
|
|
@@ -17,9 +19,9 @@ def _max_width_():
|
|
| 17 |
""",
|
| 18 |
unsafe_allow_html=True,
|
| 19 |
)
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
col1, col2, col3 = st.columns([1,6,1])
|
| 24 |
with col1:
|
| 25 |
st.image("https://cdna.artstation.com/p/assets/images/images/054/900/558/large/aaron-wacker-pen-and-ink-castle-of-the-light-wing-angels.jpg?1665625788",width=80,)
|
|
@@ -28,6 +30,7 @@ with col2:
|
|
| 28 |
with col3:
|
| 29 |
st.image("https://cdna.artstation.com/p/assets/images/images/054/900/558/small/aaron-wacker-pen-and-ink-castle-of-the-light-wing-angels.jpg?1665625788",width=80,)
|
| 30 |
|
|
|
|
| 31 |
c29, c30, c31 = st.columns([1, 6, 1])
|
| 32 |
with c30:
|
| 33 |
uploaded_file = st.file_uploader("", key="1", help="To activate 'wide mode', go to the menu > Settings > turn on 'wide mode'",)
|
|
@@ -37,12 +40,14 @@ with c30:
|
|
| 37 |
uploaded_file.seek(0)
|
| 38 |
file_container.write(shows)
|
| 39 |
else:
|
| 40 |
-
st.info(f"""⬆️Upload a 📝.CSV file. AI
|
| 41 |
st.stop()
|
|
|
|
|
|
|
| 42 |
gb = GridOptionsBuilder.from_dataframe(shows)
|
| 43 |
gb.configure_default_column(enablePivot=True, enableValue=True, enableRowGroup=True)
|
| 44 |
gb.configure_selection(selection_mode="multiple", use_checkbox=True)
|
| 45 |
-
gb.configure_side_bar()
|
| 46 |
gridOptions = gb.build()
|
| 47 |
st.success(f"""💡 Tip! Hold shift key when selecting rows to select multiple rows at once.""")
|
| 48 |
response = AgGrid(
|
|
@@ -53,21 +58,17 @@ response = AgGrid(
|
|
| 53 |
data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
|
| 54 |
fit_columns_on_grid_load=False,
|
| 55 |
)
|
|
|
|
|
|
|
| 56 |
df = pd.DataFrame(response["selected_rows"])
|
| 57 |
st.subheader("Filtered data will appear below 📊 ")
|
| 58 |
st.text("")
|
| 59 |
st.table(df)
|
| 60 |
st.text("")
|
|
|
|
|
|
|
| 61 |
c29, c30, c31 = st.columns([1, 1, 2])
|
| 62 |
with c29:
|
| 63 |
-
CSVButton = download_button(
|
| 64 |
-
df,
|
| 65 |
-
"File.csv",
|
| 66 |
-
"Download CSV file",
|
| 67 |
-
)
|
| 68 |
with c30:
|
| 69 |
-
CSVButton = download_button(
|
| 70 |
-
df,
|
| 71 |
-
"File.csv",
|
| 72 |
-
"Download TXT file",
|
| 73 |
-
)
|
|
|
|
| 5 |
from st_aggrid.shared import JsCode
|
| 6 |
from download import download_button
|
| 7 |
from st_aggrid import GridUpdateMode, DataReturnMode
|
| 8 |
+
|
| 9 |
+
# Style
|
| 10 |
def _max_width_():
|
| 11 |
max_width_str = f"max-width: 1800px;"
|
| 12 |
st.markdown(
|
|
|
|
| 19 |
""",
|
| 20 |
unsafe_allow_html=True,
|
| 21 |
)
|
| 22 |
+
|
| 23 |
+
# Page and Title Bar with Images and Icons
|
| 24 |
+
st.set_page_config(page_icon="📝", page_title="📝CSV Data Analyzer📊")
|
| 25 |
col1, col2, col3 = st.columns([1,6,1])
|
| 26 |
with col1:
|
| 27 |
st.image("https://cdna.artstation.com/p/assets/images/images/054/900/558/large/aaron-wacker-pen-and-ink-castle-of-the-light-wing-angels.jpg?1665625788",width=80,)
|
|
|
|
| 30 |
with col3:
|
| 31 |
st.image("https://cdna.artstation.com/p/assets/images/images/054/900/558/small/aaron-wacker-pen-and-ink-castle-of-the-light-wing-angels.jpg?1665625788",width=80,)
|
| 32 |
|
| 33 |
+
# Upload
|
| 34 |
c29, c30, c31 = st.columns([1, 6, 1])
|
| 35 |
with c30:
|
| 36 |
uploaded_file = st.file_uploader("", key="1", help="To activate 'wide mode', go to the menu > Settings > turn on 'wide mode'",)
|
|
|
|
| 40 |
uploaded_file.seek(0)
|
| 41 |
file_container.write(shows)
|
| 42 |
else:
|
| 43 |
+
st.info(f"""⬆️Upload a 📝.CSV file. AI Example Datasets: [Carddata.csv](https://huggingface.co/datasets/awacke1/Carddata.csv) [MindfulStory.csv](https://huggingface.co/datasets/awacke1/MindfulStory.csv) [WikipediaSearch](https://huggingface.co/datasets/awacke1/WikipediaSearch)""")
|
| 44 |
st.stop()
|
| 45 |
+
|
| 46 |
+
# DisplayGrid
|
| 47 |
gb = GridOptionsBuilder.from_dataframe(shows)
|
| 48 |
gb.configure_default_column(enablePivot=True, enableValue=True, enableRowGroup=True)
|
| 49 |
gb.configure_selection(selection_mode="multiple", use_checkbox=True)
|
| 50 |
+
gb.configure_side_bar()
|
| 51 |
gridOptions = gb.build()
|
| 52 |
st.success(f"""💡 Tip! Hold shift key when selecting rows to select multiple rows at once.""")
|
| 53 |
response = AgGrid(
|
|
|
|
| 58 |
data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
|
| 59 |
fit_columns_on_grid_load=False,
|
| 60 |
)
|
| 61 |
+
|
| 62 |
+
# Filters
|
| 63 |
df = pd.DataFrame(response["selected_rows"])
|
| 64 |
st.subheader("Filtered data will appear below 📊 ")
|
| 65 |
st.text("")
|
| 66 |
st.table(df)
|
| 67 |
st.text("")
|
| 68 |
+
|
| 69 |
+
# Download
|
| 70 |
c29, c30, c31 = st.columns([1, 1, 2])
|
| 71 |
with c29:
|
| 72 |
+
CSVButton = download_button(df,"File.csv","Download CSV file",)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
with c30:
|
| 74 |
+
CSVButton = download_button(df,"File.csv","Download TXT file",)
|
|
|
|
|
|
|
|
|
|
|
|