Update app.py
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ def process_file(input_file):
|
|
| 24 |
"""Process uploaded Excel file and return output"""
|
| 25 |
try:
|
| 26 |
# Read input file
|
| 27 |
-
input_df = pd.read_excel(input_file
|
| 28 |
|
| 29 |
# Store original date order
|
| 30 |
date_columns = input_df.columns[1:].tolist()
|
|
@@ -60,7 +60,8 @@ def process_file(input_file):
|
|
| 60 |
return final_df, tmp.name
|
| 61 |
|
| 62 |
except Exception as e:
|
| 63 |
-
|
|
|
|
| 64 |
|
| 65 |
# Gradio interface
|
| 66 |
with gr.Blocks(title="Schedule Processor") as demo:
|
|
@@ -68,7 +69,7 @@ with gr.Blocks(title="Schedule Processor") as demo:
|
|
| 68 |
gr.Markdown("Upload your schedule Excel file and download the formatted version")
|
| 69 |
|
| 70 |
with gr.Row():
|
| 71 |
-
input_file = gr.File(label="Upload Schedule File", type="
|
| 72 |
output_file = gr.File(label="Download Processed File", visible=False)
|
| 73 |
|
| 74 |
output_table = gr.Dataframe(label="Preview", headers=[])
|
|
@@ -78,8 +79,8 @@ with gr.Blocks(title="Schedule Processor") as demo:
|
|
| 78 |
def process_and_show(file):
|
| 79 |
df, out_path = process_file(file)
|
| 80 |
if out_path:
|
| 81 |
-
return df, gr.File.update(value=out_path, visible=True)
|
| 82 |
-
return df, gr.File.update(visible=False)
|
| 83 |
|
| 84 |
btn.click(
|
| 85 |
process_and_show,
|
|
|
|
| 24 |
"""Process uploaded Excel file and return output"""
|
| 25 |
try:
|
| 26 |
# Read input file
|
| 27 |
+
input_df = pd.read_excel(input_file, header=1)
|
| 28 |
|
| 29 |
# Store original date order
|
| 30 |
date_columns = input_df.columns[1:].tolist()
|
|
|
|
| 60 |
return final_df, tmp.name
|
| 61 |
|
| 62 |
except Exception as e:
|
| 63 |
+
error_df = pd.DataFrame({"Error": [f"⚠️ {str(e)}"]})
|
| 64 |
+
return error_df, None
|
| 65 |
|
| 66 |
# Gradio interface
|
| 67 |
with gr.Blocks(title="Schedule Processor") as demo:
|
|
|
|
| 69 |
gr.Markdown("Upload your schedule Excel file and download the formatted version")
|
| 70 |
|
| 71 |
with gr.Row():
|
| 72 |
+
input_file = gr.File(label="Upload Schedule File", type="filepath")
|
| 73 |
output_file = gr.File(label="Download Processed File", visible=False)
|
| 74 |
|
| 75 |
output_table = gr.Dataframe(label="Preview", headers=[])
|
|
|
|
| 79 |
def process_and_show(file):
|
| 80 |
df, out_path = process_file(file)
|
| 81 |
if out_path:
|
| 82 |
+
return df, gr.File.update(value=out_path, visible=True)
|
| 83 |
+
return df, gr.File.update(visible=False)
|
| 84 |
|
| 85 |
btn.click(
|
| 86 |
process_and_show,
|