Spaces:
Sleeping
Sleeping
File size: 566 Bytes
31801e9 af22e18 31801e9 af22e18 31801e9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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
|