A2D / dataset_import.py
Abu1998's picture
Update dataset_import.py
c64d36b verified
raw
history blame contribute delete
646 Bytes
import os
import pandas as pd
import streamlit as st
def load_data():
# List available files in the data directory
available_files = [f for f in os.listdir('./data') if f.endswith('.csv')]
if len(available_files) == 0:
st.error("No CSV files found in the dataset folder.")
return None
# Ask user to select which file to load
selected_file = st.selectbox('Select a file to load', available_files)
if selected_file:
# Load the selected dataset
data = pd.read_csv(f'./data/{selected_file}')
return data
else:
st.error("Please select a valid file.")
return None