shrudhit commited on
Commit
e7a8378
·
verified ·
1 Parent(s): bd48e9c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+
4
+ def process_file(file):
5
+ df = pd.read_excel(file.name, header=None)
6
+
7
+ # delete first 4 rows
8
+ df = df.iloc[4:].reset_index(drop=True)
9
+
10
+ # make sure columns up to J exist
11
+ while df.shape[1] < 10:
12
+ df[df.shape[1]] = ""
13
+
14
+ # column H = I - J
15
+ df.iloc[:,7] = df.iloc[:,8] - df.iloc[:,9]
16
+
17
+ output = "output.csv"
18
+ df.to_csv(output, index=False, header=False)
19
+
20
+ return output
21
+
22
+
23
+ demo = gr.Interface(
24
+ fn=process_file,
25
+ inputs=gr.File(label="Upload Excel File"),
26
+ outputs=gr.File(label="Download CSV"),
27
+ title="Excel to CSV Tool"
28
+ )
29
+
30
+ demo.launch()