Spaces:
Sleeping
Sleeping
gracefully handle CSV
Browse files
app.py
CHANGED
|
@@ -38,7 +38,7 @@ def classify_comments():
|
|
| 38 |
|
| 39 |
# Gradio Interface
|
| 40 |
with gr.Blocks() as nps:
|
| 41 |
-
uploaded_file = gr.File(label="Upload CSV",
|
| 42 |
template_btn = gr.Button("Use Template")
|
| 43 |
gr.Markdown("# NPS Comment Categorization")
|
| 44 |
classify_btn = gr.Button("Classify Comments")
|
|
@@ -49,7 +49,8 @@ with gr.Blocks() as nps:
|
|
| 49 |
file.seek(0) # Reset file pointer
|
| 50 |
import io
|
| 51 |
if file.name.endswith('.csv'):
|
| 52 |
-
|
|
|
|
| 53 |
custom_df = pd.read_csv(io.StringIO(content))
|
| 54 |
else:
|
| 55 |
return "Error: Uploaded file is not a CSV."
|
|
|
|
| 38 |
|
| 39 |
# Gradio Interface
|
| 40 |
with gr.Blocks() as nps:
|
| 41 |
+
uploaded_file = gr.File(label="Upload CSV", type="file")
|
| 42 |
template_btn = gr.Button("Use Template")
|
| 43 |
gr.Markdown("# NPS Comment Categorization")
|
| 44 |
classify_btn = gr.Button("Classify Comments")
|
|
|
|
| 49 |
file.seek(0) # Reset file pointer
|
| 50 |
import io
|
| 51 |
if file.name.endswith('.csv'):
|
| 52 |
+
file.seek(0) # Reset file pointer
|
| 53 |
+
custom_df = pd.read_csv(file)
|
| 54 |
custom_df = pd.read_csv(io.StringIO(content))
|
| 55 |
else:
|
| 56 |
return "Error: Uploaded file is not a CSV."
|