Update app.py
Browse files
app.py
CHANGED
|
@@ -3,22 +3,24 @@ import pandas as pd
|
|
| 3 |
|
| 4 |
def process_file(file_path):
|
| 5 |
|
| 6 |
-
# read correct sheet
|
| 7 |
df = pd.read_excel(file_path, sheet_name="Price Recommendations-Fill This", header=None)
|
| 8 |
|
| 9 |
-
#
|
| 10 |
df = df.iloc[4:].reset_index(drop=True)
|
| 11 |
|
| 12 |
# ensure at least 10 columns
|
| 13 |
while df.shape[1] < 10:
|
| 14 |
df[df.shape[1]] = 0
|
| 15 |
|
| 16 |
-
# convert
|
| 17 |
col_i = pd.to_numeric(df.iloc[:,8], errors="coerce").fillna(0)
|
| 18 |
col_j = pd.to_numeric(df.iloc[:,9], errors="coerce").fillna(0)
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
df.iloc[:,7] =
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# save csv
|
| 24 |
output = "/tmp/output.csv"
|
|
@@ -31,7 +33,7 @@ demo = gr.Interface(
|
|
| 31 |
fn=process_file,
|
| 32 |
inputs=gr.File(type="filepath"),
|
| 33 |
outputs=gr.File(),
|
| 34 |
-
title="Excel
|
| 35 |
)
|
| 36 |
|
| 37 |
demo.launch()
|
|
|
|
| 3 |
|
| 4 |
def process_file(file_path):
|
| 5 |
|
|
|
|
| 6 |
df = pd.read_excel(file_path, sheet_name="Price Recommendations-Fill This", header=None)
|
| 7 |
|
| 8 |
+
# remove first 4 rows
|
| 9 |
df = df.iloc[4:].reset_index(drop=True)
|
| 10 |
|
| 11 |
# ensure at least 10 columns
|
| 12 |
while df.shape[1] < 10:
|
| 13 |
df[df.shape[1]] = 0
|
| 14 |
|
| 15 |
+
# convert I and J
|
| 16 |
col_i = pd.to_numeric(df.iloc[:,8], errors="coerce").fillna(0)
|
| 17 |
col_j = pd.to_numeric(df.iloc[:,9], errors="coerce").fillna(0)
|
| 18 |
|
| 19 |
+
# H = I - J
|
| 20 |
+
df.iloc[:,7] = col_i - col_j
|
| 21 |
+
|
| 22 |
+
# keep only rows where H < 59
|
| 23 |
+
df = df[df.iloc[:,7] < 59]
|
| 24 |
|
| 25 |
# save csv
|
| 26 |
output = "/tmp/output.csv"
|
|
|
|
| 33 |
fn=process_file,
|
| 34 |
inputs=gr.File(type="filepath"),
|
| 35 |
outputs=gr.File(),
|
| 36 |
+
title="Excel Filter Tool"
|
| 37 |
)
|
| 38 |
|
| 39 |
demo.launch()
|