Spaces:
Sleeping
Sleeping
Update ingest.py
Browse files
ingest.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import pandas as pd
|
|
|
|
| 2 |
|
| 3 |
def load_data(filepath):
|
| 4 |
# Check the file extension and load the file accordingly
|
|
@@ -7,7 +8,7 @@ def load_data(filepath):
|
|
| 7 |
elif filepath.endswith('.xlsx') or filepath.endswith('.xls'):
|
| 8 |
df = pd.read_excel(filepath)
|
| 9 |
else:
|
| 10 |
-
raise
|
| 11 |
|
| 12 |
# Convert all string values to lowercase and remove spaces
|
| 13 |
df = df.map(lambda x: x.lower().replace(" ", "") if isinstance(x, str) else x)
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
import gradio as gr
|
| 3 |
|
| 4 |
def load_data(filepath):
|
| 5 |
# Check the file extension and load the file accordingly
|
|
|
|
| 8 |
elif filepath.endswith('.xlsx') or filepath.endswith('.xls'):
|
| 9 |
df = pd.read_excel(filepath)
|
| 10 |
else:
|
| 11 |
+
raise gr.Error("Unsupported file format: Please provide a .csv or .xlsx file")
|
| 12 |
|
| 13 |
# Convert all string values to lowercase and remove spaces
|
| 14 |
df = df.map(lambda x: x.lower().replace(" ", "") if isinstance(x, str) else x)
|