awacke1 commited on
Commit
f1d0d9d
·
1 Parent(s): 941efc9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import plotly.express as px
4
+
5
+ # Define the function to load the CSV file
6
+ def load_data(file):
7
+ df = pd.read_csv(file)
8
+ return df
9
+
10
+ # Create the input interface for the CSV file
11
+ inputs = gr.inputs.UploadButton(label="Upload your CSV file:")
12
+
13
+ # Define the main function that will be called when the user submits their file
14
+ def main(inputs):
15
+ df = load_data(inputs)
16
+ return df
17
+
18
+ # Create the output interface for the DataFrame
19
+ outputs = gr.outputs.Dataframe(examples={"file1.csv": "path/to/file1.csv",
20
+ "file2.csv": "path/to/file2.csv",
21
+ "file3.csv": "path/to/file3.csv"})
22
+
23
+ # Create the Plot output interface
24
+ plot = gr.outputs.Plotly(click_submit_button=True)
25
+
26
+ # Define the plot function that will be called when the user selects their options
27
+ def plot_function(df, x, y):
28
+ fig = px.scatter(df, x=x, y=y)
29
+ return fig
30
+
31
+ # Create the Gradio interface
32
+ interface = gr.Interface(fn=main, inputs=inputs, outputs=outputs, title="CSV Plotter", plot=plot, plot_fn=plot_function)
33
+ interface.launch()