danial0203 commited on
Commit
61167a1
1 Parent(s): dd7dd6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
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
- file_path = file.name
82
- file.save(file_path)
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
- os.remove(file_path) # Clean up uploaded file
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,