Update csv_display.py
Browse files- csv_display.py +17 -8
csv_display.py
CHANGED
|
@@ -1,6 +1,3 @@
|
|
| 1 |
-
import pandas as pd
|
| 2 |
-
import streamlit as st
|
| 3 |
-
|
| 4 |
def csv_display():
|
| 5 |
# Prompt user for CSV path
|
| 6 |
df_path = st.text_input("Enter the CSV Path to display:")
|
|
@@ -17,17 +14,29 @@ def csv_display():
|
|
| 17 |
|
| 18 |
# Select page number
|
| 19 |
if df is not None:
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
# Select columns to display
|
| 23 |
display_cols = df.columns
|
| 24 |
columns_to_display = st.multiselect("Select Columns to Display", df.columns)
|
| 25 |
|
| 26 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
if len(columns_to_display) > 0:
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
else:
|
| 30 |
st.write("No columns selected")
|
| 31 |
else:
|
| 32 |
-
st.write("DataFrame not found")
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def csv_display():
|
| 2 |
# Prompt user for CSV path
|
| 3 |
df_path = st.text_input("Enter the CSV Path to display:")
|
|
|
|
| 14 |
|
| 15 |
# Select page number
|
| 16 |
if df is not None:
|
| 17 |
+
page_numbers = ['all'] + list(set(df['Page#'].values))
|
| 18 |
+
page_number = st.selectbox("Select the Page Number:", options=page_numbers, index=0)
|
| 19 |
|
| 20 |
# Select columns to display
|
| 21 |
display_cols = df.columns
|
| 22 |
columns_to_display = st.multiselect("Select Columns to Display", df.columns)
|
| 23 |
|
| 24 |
+
# Handle page number change
|
| 25 |
+
def on_page_change(new_page):
|
| 26 |
+
st.write(df[df['Page#'] == new_page][columns_to_display] if new_page != 'all' else df[columns_to_display])
|
| 27 |
+
|
| 28 |
+
st.write("### Display Data")
|
| 29 |
+
st.write("Page number selected:", page_number)
|
| 30 |
+
st.write("Columns selected:", columns_to_display)
|
| 31 |
+
|
| 32 |
+
# Display selected columns based on page selection
|
| 33 |
if len(columns_to_display) > 0:
|
| 34 |
+
if page_number == 'all':
|
| 35 |
+
st.write(df[columns_to_display])
|
| 36 |
+
else:
|
| 37 |
+
on_page_change(page_number)
|
| 38 |
+
st.selectbox("Select the Page Number:", options=page_numbers, index=page_numbers.index(page_number), on_change=on_page_change)
|
| 39 |
else:
|
| 40 |
st.write("No columns selected")
|
| 41 |
else:
|
| 42 |
+
st.write("DataFrame not found")
|
|
|