codys12 commited on
Commit
fe90c9a
·
verified ·
1 Parent(s): 354bf5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -14,7 +14,7 @@ def process_woocommerce_data_in_memory(netcom_file):
14
  "Microsoft": "https://devthe.tech/wp-content/uploads/2025/01/Microsoft-e1737494120985-1.png"
15
  }
16
 
17
- # 1. Read the uploaded CSV into a DataFrame
18
  netcom_df = pd.read_csv(netcom_file.name, encoding='latin1')
19
  netcom_df.columns = netcom_df.columns.str.strip() # standardize column names
20
 
@@ -150,16 +150,18 @@ def process_woocommerce_data_in_memory(netcom_file):
150
 
151
  def process_file_and_return_csv(uploaded_file):
152
  """
153
- Gradio wrapper function:
154
  - Takes the uploaded file,
155
  - Processes it,
156
- - Returns a tuple that Gradio can interpret as a downloadable file.
157
  """
158
  processed_csv_io = process_woocommerce_data_in_memory(uploaded_file)
159
 
160
- # Gradio expects a tuple (filename, file_obj) when returning a downloadable file
161
- return ("WooCommerce_Mapped_Data.csv", processed_csv_io.getvalue())
162
-
 
 
163
 
164
  #########################
165
  # Gradio App #
 
14
  "Microsoft": "https://devthe.tech/wp-content/uploads/2025/01/Microsoft-e1737494120985-1.png"
15
  }
16
 
17
+ # 1. Read the uploaded CSV into a DataFrame (Gradio provides a tempfile-like object)
18
  netcom_df = pd.read_csv(netcom_file.name, encoding='latin1')
19
  netcom_df.columns = netcom_df.columns.str.strip() # standardize column names
20
 
 
150
 
151
  def process_file_and_return_csv(uploaded_file):
152
  """
153
+ Gradio wrapper function that:
154
  - Takes the uploaded file,
155
  - Processes it,
156
+ - Returns a dictionary that Gradio recognizes as a downloadable file.
157
  """
158
  processed_csv_io = process_woocommerce_data_in_memory(uploaded_file)
159
 
160
+ # Return a dict with the keys Gradio expects for a File output
161
+ return {
162
+ "name": "WooCommerce_Mapped_Data.csv",
163
+ "data": processed_csv_io.getvalue()
164
+ }
165
 
166
  #########################
167
  # Gradio App #