Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -78,8 +78,8 @@ def get_text(result, blocks_map):
|
|
| 78 |
return text.strip()
|
| 79 |
|
| 80 |
def process_file_and_generate_csv(file):
|
| 81 |
-
|
| 82 |
-
file.
|
| 83 |
|
| 84 |
csv_output_path = "/tmp/output.csv"
|
| 85 |
|
|
@@ -99,9 +99,10 @@ def process_file_and_generate_csv(file):
|
|
| 99 |
tables = [block for block in blocks if block['BlockType'] == "TABLE"]
|
| 100 |
generate_table_csv(tables, blocks_map, csv_output_path)
|
| 101 |
|
| 102 |
-
|
| 103 |
return csv_output_path, "Processing completed successfully!"
|
| 104 |
|
|
|
|
| 105 |
# Gradio Interface
|
| 106 |
iface = gr.Interface(
|
| 107 |
fn=process_file_and_generate_csv,
|
|
|
|
| 78 |
return text.strip()
|
| 79 |
|
| 80 |
def process_file_and_generate_csv(file):
|
| 81 |
+
# Directly use the file path provided by Gradio
|
| 82 |
+
file_path = file.name if isinstance(file, gr.files.File) else file
|
| 83 |
|
| 84 |
csv_output_path = "/tmp/output.csv"
|
| 85 |
|
|
|
|
| 99 |
tables = [block for block in blocks if block['BlockType'] == "TABLE"]
|
| 100 |
generate_table_csv(tables, blocks_map, csv_output_path)
|
| 101 |
|
| 102 |
+
# Return the CSV output path for Gradio to handle the file download
|
| 103 |
return csv_output_path, "Processing completed successfully!"
|
| 104 |
|
| 105 |
+
|
| 106 |
# Gradio Interface
|
| 107 |
iface = gr.Interface(
|
| 108 |
fn=process_file_and_generate_csv,
|