Spaces:
Running
on
Zero
Running
on
Zero
file validation
Browse files
app.py
CHANGED
@@ -47,7 +47,12 @@ with gr.Blocks() as nps:
|
|
47 |
def load_data(file):
|
48 |
if file is not None:
|
49 |
file.seek(0) # Reset file pointer
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
51 |
if 'customer_comment' not in custom_df.columns:
|
52 |
return "Error: Uploaded CSV must contain a column named 'customer_comment'"
|
53 |
global df
|
|
|
47 |
def load_data(file):
|
48 |
if file is not None:
|
49 |
file.seek(0) # Reset file pointer
|
50 |
+
import io
|
51 |
+
if file.name.endswith('.csv'):
|
52 |
+
content = file.read().decode('utf-8')
|
53 |
+
custom_df = pd.read_csv(io.StringIO(content))
|
54 |
+
else:
|
55 |
+
return "Error: Uploaded file is not a CSV."
|
56 |
if 'customer_comment' not in custom_df.columns:
|
57 |
return "Error: Uploaded CSV must contain a column named 'customer_comment'"
|
58 |
global df
|