rameshmoorthy
commited on
Commit
•
9f18ee5
1
Parent(s):
b389679
Update app.py
Browse files
app.py
CHANGED
@@ -41,8 +41,21 @@ with gr.Blocks() as bm25:
|
|
41 |
|
42 |
#german = gr.Textbox(label="German Text")
|
43 |
def confirmation():
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
def download_doc(doc):
|
48 |
return doc
|
|
|
41 |
|
42 |
#german = gr.Textbox(label="German Text")
|
43 |
def confirmation():
|
44 |
+
if file.name.endswith('.csv'):
|
45 |
+
df = pd.read_csv(file)
|
46 |
+
elif file.name.endswith('.xls') or file.name.endswith('.xlsx'):
|
47 |
+
df = pd.read_excel(file)
|
48 |
+
else:
|
49 |
+
doc = "Unsupported file format. Please provide a CSV or Excel file."
|
50 |
+
return doc # Return immediately with the error message
|
51 |
+
|
52 |
+
# Ensure that the 'products' column is present in the dataframe
|
53 |
+
if 'products' not in df.columns.str.lower():
|
54 |
+
doc = "The input file must have a column named 'products'."
|
55 |
+
return doc # Return immediately with the error message
|
56 |
+
|
57 |
+
doc = 'File uploaded! Press Cluster button'
|
58 |
+
return doc # Return the success message
|
59 |
|
60 |
def download_doc(doc):
|
61 |
return doc
|