kelvinleong commited on
Commit
fa0686b
·
1 Parent(s): d995a24

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+
4
+ def modify_csv(input_csv):
5
+ # Load the input CSV file into a pandas DataFrame
6
+ df = pd.read_csv(input_csv)
7
+
8
+ # Modify the DataFrame (in this example, just add 1 to all values)
9
+ df = df + 1
10
+
11
+ # Save the modified DataFrame to a new CSV file
12
+ output_csv = 'output.csv'
13
+ df.to_csv(output_csv, index=False)
14
+
15
+ # Return the path to the output CSV file
16
+ return output_csv
17
+
18
+ # Define the input and output types for the Gradio interface
19
+ input_type = gr.inputs.Dataframe(type="csv", label="Upload a CSV file")
20
+ output_type = gr.outputs.File(type="csv", label="Download the modified CSV file")
21
+
22
+ # Create the Gradio interface
23
+ iface = gr.Interface(fn=modify_csv, inputs=input_type, outputs=output_type, title="CSV Modifier")
24
+
25
+ # Launch the interface
26
+ iface.launch()