Spaces:
Runtime error
Runtime error
test
Browse files
app.py
CHANGED
|
@@ -8,13 +8,32 @@ from io import BytesIO
|
|
| 8 |
# Global variable to store the loaded DataFrame
|
| 9 |
df = None
|
| 10 |
wb = None
|
|
|
|
| 11 |
|
| 12 |
def greet(name):
|
| 13 |
return "Hello " + name + "!!"
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# Load the Excel file
|
| 16 |
def load_excel(file):
|
| 17 |
-
global df, wb
|
| 18 |
wb = load_workbook(file.name)
|
| 19 |
sheet = wb.active
|
| 20 |
df = pd.DataFrame(sheet.values)
|
|
@@ -43,6 +62,17 @@ with gr.Blocks() as demo:
|
|
| 43 |
with gr.Row():
|
| 44 |
with gr.Column():
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
|
| 47 |
upload.upload(load_excel, [upload])
|
| 48 |
search_input = gr.Textbox(label="Search Text")
|
|
|
|
| 8 |
# Global variable to store the loaded DataFrame
|
| 9 |
df = None
|
| 10 |
wb = None
|
| 11 |
+
options = None
|
| 12 |
|
| 13 |
def greet(name):
|
| 14 |
return "Hello " + name + "!!"
|
| 15 |
|
| 16 |
+
# Load the Excel file from Github
|
| 17 |
+
def load_excel_from_github():
|
| 18 |
+
global df, wb, options
|
| 19 |
+
|
| 20 |
+
url = "https://github.com/mmlanla/image_share/blob/main/mass_update_sales_info_lastest.xlsx?raw=true"
|
| 21 |
+
response = requests.get(url)
|
| 22 |
+
file_data = BytesIO(response.content)
|
| 23 |
+
wb = load_workbook(file_data)
|
| 24 |
+
|
| 25 |
+
sheet = wb.active
|
| 26 |
+
df = pd.DataFrame(sheet.values)
|
| 27 |
+
df.columns = df.iloc[0] # Set the first row as column names
|
| 28 |
+
df = df[1:] # Remove the first row from the DataFrame
|
| 29 |
+
options = df['et_title_variation_name'].unique().tolist()
|
| 30 |
+
print('options',options)
|
| 31 |
+
return options
|
| 32 |
+
|
| 33 |
+
|
| 34 |
# Load the Excel file
|
| 35 |
def load_excel(file):
|
| 36 |
+
global df, wb, options
|
| 37 |
wb = load_workbook(file.name)
|
| 38 |
sheet = wb.active
|
| 39 |
df = pd.DataFrame(sheet.values)
|
|
|
|
| 62 |
with gr.Row():
|
| 63 |
with gr.Column():
|
| 64 |
|
| 65 |
+
# -------- load_excel_from_github ---------
|
| 66 |
+
|
| 67 |
+
button_load_excel_from_github = gr.Button("load_excel_from_github")
|
| 68 |
+
output_message = gr.Textbox(label="Output Message", interactive=False)
|
| 69 |
+
button_load_excel_from_github.click(
|
| 70 |
+
fn=load_excel_from_github,
|
| 71 |
+
inputs=[],
|
| 72 |
+
outputs=output_message
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
# -------- upload_excel ---------
|
| 76 |
upload = gr.File(label="Upload Excel File", file_types=[".xlsx"])
|
| 77 |
upload.upload(load_excel, [upload])
|
| 78 |
search_input = gr.Textbox(label="Search Text")
|