gaur3009 commited on
Commit
40197c3
·
verified ·
1 Parent(s): ac81731

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -10
app.py CHANGED
@@ -11,15 +11,22 @@ import warnings
11
 
12
  warnings.filterwarnings("ignore")
13
 
14
- # Function to read and process uploaded file
15
  def read_file(file):
16
- if file.name.endswith(".csv"):
17
- df = pd.read_csv(file)
18
- elif file.name.endswith(".xlsx"):
19
- df = pd.read_excel(file)
20
- else:
21
- raise ValueError("Unsupported file format. Please upload a CSV or Excel file.")
22
- return df
 
 
 
 
 
 
 
 
23
 
24
  # Clean the data
25
  def clean_data(df):
@@ -168,6 +175,5 @@ def gradio_interface():
168
 
169
  return interface
170
 
171
- # Launch the Gradio interface
172
  interface = gradio_interface()
173
- interface.launch(debug=True)
 
11
 
12
  warnings.filterwarnings("ignore")
13
 
 
14
  def read_file(file):
15
+ try:
16
+ if file.name.endswith(".csv"):
17
+ df = pd.read_csv(file)
18
+ elif file.name.endswith(".xlsx"):
19
+ df = pd.read_excel(file)
20
+ else:
21
+ raise ValueError("Unsupported file format. Please upload a CSV or Excel file.")
22
+
23
+ # Ensure the file has columns
24
+ if df.empty or df.columns.size == 0:
25
+ raise ValueError("The file has no data or valid columns to parse.")
26
+
27
+ return df
28
+ except Exception as e:
29
+ raise ValueError(f"Error reading file: {str(e)}")
30
 
31
  # Clean the data
32
  def clean_data(df):
 
175
 
176
  return interface
177
 
 
178
  interface = gradio_interface()
179
+ interface.launch(debug=True)