import pandas as pd import gradio as gr def load_data(filepath): # Check the file extension and load the file accordingly if filepath.endswith('.csv'): df = pd.read_csv(filepath) elif filepath.endswith('.xlsx') or filepath.endswith('.xls'): df = pd.read_excel(filepath) else: raise gr.Error("Unsupported file format: Please provide a .csv or .xlsx file") # Convert all string values to lowercase and remove spaces df = df.map(lambda x: x.lower().replace(" ", "") if isinstance(x, str) else x) return df