File size: 1,170 Bytes
e7a8378 f992abc 59b0c26 f992abc e7a8378 f992abc e7a8378 f992abc e7a8378 f992abc 2d40501 f992abc 9cbef49 f992abc e7a8378 f992abc a3aacf0 f992abc e7a8378 4cc9f24 e7a8378 f992abc e7a8378 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import gradio as gr
import pandas as pd
def process_files(files):
all_data = []
for file in files:
df = pd.read_excel(file.name, sheet_name="Price Recommendations-Fill This", header=None)
# remove first 4 rows
df = df.iloc[4:].reset_index(drop=True)
# ensure at least 10 columns
while df.shape[1] < 10:
df[df.shape[1]] = 0
# convert columns I and J
col_i = pd.to_numeric(df.iloc[:,8], errors="coerce").fillna(0)
col_j = pd.to_numeric(df.iloc[:,9], errors="coerce").fillna(0)
# H = I - J
df.iloc[:,7] = col_i - col_j
# filter H < 59
df = df[df.iloc[:,7] < 59]
all_data.append(df)
# merge all files
merged = pd.concat(all_data)
# sort H column low → high
merged = merged.sort_values(by=7)
output = "/tmp/merged_output.csv"
merged.to_csv(output, index=False, header=False)
return output
demo = gr.Interface(
fn=process_files,
inputs=gr.File(file_count="multiple", label="Upload Excel Files"),
outputs=gr.File(label="Download Merged CSV"),
title="Bulk Excel Pricing Tool"
)
demo.launch() |