import streamlit as st import pandas as pd import os from pygwalker.api.streamlit import StreamlitRenderer @st.cache_resource def get_pyg_renderer(file_path): df = pd.read_csv(file_path) # If you want to use feature of saving chart config, set `spec_io_mode="rw"` return StreamlitRenderer(df) st.set_page_config(page_title='Data Visualizer', layout='wide', page_icon='📊') # Title st.title('📊 Data Visualizer') current_dir = os.getcwd() # Get the parent directory (one level up) #parent_dir = os.path.dirname(current_dir) folder_path = current_dir+"/data" # List all files in the folder files = [f for f in os.listdir(folder_path) if f.endswith('.csv')] # Dropdown to select a file selected_file = st.selectbox('Select a file', files, index=None) # if selected_file: # Construct the full path to the file file_path = os.path.join(folder_path, selected_file) # Read the selected CSV file renderer = get_pyg_renderer(file_path) renderer.explorer()