jkushwaha commited on
Commit
044d339
·
verified ·
1 Parent(s): a415c54

Update csv_display.py

Browse files
Files changed (1) hide show
  1. csv_display.py +21 -3
csv_display.py CHANGED
@@ -1,15 +1,33 @@
 
 
 
1
  def csv_display():
 
2
  df_path = st.text_input("Enter the CSV Path to display:")
 
 
3
  st.write("### Display DataFrame")
4
- df = pd.read_csv(df_path)
5
- page_number = st.selectbox("Select the Page Number:", options=['all']+list(set(df['Page#'].values)), index=0)
6
 
7
- display_cols = df.columns
 
 
 
 
 
 
 
8
  if df is not None:
 
 
 
 
9
  columns_to_display = st.multiselect("Select Columns to Display", df.columns)
 
 
10
  if len(columns_to_display) > 0:
11
  st.write(df[columns_to_display])
12
  else:
13
  st.write("No columns selected")
14
  else:
15
  st.write("DataFrame not found")
 
 
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:")
7
+
8
+ # Display DataFrame
9
  st.write("### Display DataFrame")
 
 
10
 
11
+ # Read CSV file
12
+ try:
13
+ df = pd.read_csv(df_path)
14
+ except Exception as e:
15
+ st.error(f"Error: {e}")
16
+ return
17
+
18
+ # Select page number
19
  if df is not None:
20
+ page_number = st.selectbox("Select the Page Number:", options=['all']+list(set(df['Page#'].values)), index=0)
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
+ # Display selected columns
27
  if len(columns_to_display) > 0:
28
  st.write(df[columns_to_display])
29
  else:
30
  st.write("No columns selected")
31
  else:
32
  st.write("DataFrame not found")
33
+