Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -379,6 +379,7 @@ def process_file(file_obj, topic_prefix, sentiment_prefix, category_prefix,
|
|
379 |
text_column, recommendation_column, output_format, analyze_data, selected_columns):
|
380 |
"""
|
381 |
Main processing function for Gradio interface.
|
|
|
382 |
"""
|
383 |
try:
|
384 |
# Extract actual column names from display format
|
@@ -426,7 +427,9 @@ def process_file(file_obj, topic_prefix, sentiment_prefix, category_prefix,
|
|
426 |
# Save transformed data
|
427 |
output_file = transformer.save_transformed_data(output_format)
|
428 |
status_msg += f"\nπΎ File saved successfully: {os.path.basename(output_file)}\n"
|
|
|
429 |
|
|
|
430 |
return status_msg, analysis_result, output_file
|
431 |
|
432 |
except Exception as e:
|
@@ -452,8 +455,7 @@ with gr.Blocks(title="Feedback Topic & Sentiment Transformer", css="""
|
|
452 |
1. Upload your Excel, CSV, or tab-delimited text file
|
453 |
2. Select which original columns to include in the output
|
454 |
3. Configure column prefixes (or use defaults)
|
455 |
-
4. Click "Transform Data" to process
|
456 |
-
5. Download the transformed file
|
457 |
""")
|
458 |
|
459 |
with gr.Row():
|
@@ -521,7 +523,7 @@ with gr.Blocks(title="Feedback Topic & Sentiment Transformer", css="""
|
|
521 |
)
|
522 |
|
523 |
# Transform button
|
524 |
-
transform_btn = gr.Button("π 4. Transform Data", variant="primary", size="lg")
|
525 |
|
526 |
# Output sections
|
527 |
with gr.Row():
|
@@ -537,12 +539,14 @@ with gr.Blocks(title="Feedback Topic & Sentiment Transformer", css="""
|
|
537 |
label="Data Analysis"
|
538 |
)
|
539 |
|
540 |
-
#
|
541 |
with gr.Row():
|
542 |
with gr.Column():
|
543 |
-
gr.Markdown("### π₯
|
|
|
|
|
544 |
output_file = gr.File(
|
545 |
-
label="Transformed File",
|
546 |
interactive=False,
|
547 |
visible=True
|
548 |
)
|
@@ -554,6 +558,7 @@ with gr.Blocks(title="Feedback Topic & Sentiment Transformer", css="""
|
|
554 |
outputs=[column_selector]
|
555 |
)
|
556 |
|
|
|
557 |
transform_btn.click(
|
558 |
fn=process_file,
|
559 |
inputs=[
|
@@ -589,7 +594,8 @@ with gr.Blocks(title="Feedback Topic & Sentiment Transformer", css="""
|
|
589 |
- Use the numbered column list to easily identify and select columns
|
590 |
- The text and recommendation column names in configuration are now for reference only
|
591 |
- To include them in output, select them using the column checkboxes
|
592 |
-
-
|
|
|
593 |
""")
|
594 |
|
595 |
# Launch the app
|
|
|
379 |
text_column, recommendation_column, output_format, analyze_data, selected_columns):
|
380 |
"""
|
381 |
Main processing function for Gradio interface.
|
382 |
+
Modified to return file path for automatic download.
|
383 |
"""
|
384 |
try:
|
385 |
# Extract actual column names from display format
|
|
|
427 |
# Save transformed data
|
428 |
output_file = transformer.save_transformed_data(output_format)
|
429 |
status_msg += f"\nπΎ File saved successfully: {os.path.basename(output_file)}\n"
|
430 |
+
status_msg += f"π₯ File download should start automatically\n"
|
431 |
|
432 |
+
# Return the file path directly for automatic download
|
433 |
return status_msg, analysis_result, output_file
|
434 |
|
435 |
except Exception as e:
|
|
|
455 |
1. Upload your Excel, CSV, or tab-delimited text file
|
456 |
2. Select which original columns to include in the output
|
457 |
3. Configure column prefixes (or use defaults)
|
458 |
+
4. Click "Transform Data" to process and automatically download the result
|
|
|
459 |
""")
|
460 |
|
461 |
with gr.Row():
|
|
|
523 |
)
|
524 |
|
525 |
# Transform button
|
526 |
+
transform_btn = gr.Button("π 4. Transform Data & Download", variant="primary", size="lg")
|
527 |
|
528 |
# Output sections
|
529 |
with gr.Row():
|
|
|
539 |
label="Data Analysis"
|
540 |
)
|
541 |
|
542 |
+
# Hidden download component for automatic download
|
543 |
with gr.Row():
|
544 |
with gr.Column():
|
545 |
+
gr.Markdown("### π₯ Download Status")
|
546 |
+
gr.Markdown("The transformed file will download automatically after processing completes.")
|
547 |
+
# File component that will trigger automatic download
|
548 |
output_file = gr.File(
|
549 |
+
label="Transformed File (Auto-Download)",
|
550 |
interactive=False,
|
551 |
visible=True
|
552 |
)
|
|
|
558 |
outputs=[column_selector]
|
559 |
)
|
560 |
|
561 |
+
# Modified to ensure automatic download
|
562 |
transform_btn.click(
|
563 |
fn=process_file,
|
564 |
inputs=[
|
|
|
594 |
- Use the numbered column list to easily identify and select columns
|
595 |
- The text and recommendation column names in configuration are now for reference only
|
596 |
- To include them in output, select them using the column checkboxes
|
597 |
+
- **The file will download automatically** after transformation completes
|
598 |
+
- Look for the download in your browser's download folder
|
599 |
""")
|
600 |
|
601 |
# Launch the app
|