yanivbl commited on
Commit
ccdbe83
·
1 Parent(s): 629a75b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -2,21 +2,23 @@ import gradio as gr
2
  import pandas as pd
3
  from io import StringIO
4
 
 
 
 
5
  def process_csv(file):
 
6
  if file is None:
7
  return "No file uploaded"
8
 
9
- # Read the CSV file into a DataFrame
10
- df = pd.read_csv(StringIO(file.decode("utf-8")))
11
- return df
12
 
13
  # Create the Gradio interface
14
  iface = gr.Interface(
15
  fn=process_csv,
16
- inputs=gr.File(type="binary", label="Upload CSV File"), # Changed 'csv' to 'binary'
17
- outputs="dataframe",
18
  title="CSV File Upload",
19
- description="Upload a CSV file and convert it to a pandas DataFrame."
20
  )
21
 
22
  if __name__ == "__main__":
 
2
  import pandas as pd
3
  from io import StringIO
4
 
5
+ # Global variable to hold the DataFrame
6
+ global_df = None
7
+
8
  def process_csv(file):
9
+ global global_df
10
  if file is None:
11
  return "No file uploaded"
12
 
13
+ # Read the CSV file into a DataFrame and store it in the global variable
14
+ global_df = pd.read_csv(StringIO(file.decode("utf-8")))
 
15
 
16
  # Create the Gradio interface
17
  iface = gr.Interface(
18
  fn=process_csv,
19
+ inputs=gr.File(type="binary", label="Upload CSV File"),
 
20
  title="CSV File Upload",
21
+ description="Upload a CSV file to load it into a pandas DataFrame."
22
  )
23
 
24
  if __name__ == "__main__":