awacke1's picture
Create app.py
f1d0d9d
raw
history blame
1.12 kB
import gradio as gr
import pandas as pd
import plotly.express as px
# Define the function to load the CSV file
def load_data(file):
df = pd.read_csv(file)
return df
# Create the input interface for the CSV file
inputs = gr.inputs.UploadButton(label="Upload your CSV file:")
# Define the main function that will be called when the user submits their file
def main(inputs):
df = load_data(inputs)
return df
# Create the output interface for the DataFrame
outputs = gr.outputs.Dataframe(examples={"file1.csv": "path/to/file1.csv",
"file2.csv": "path/to/file2.csv",
"file3.csv": "path/to/file3.csv"})
# Create the Plot output interface
plot = gr.outputs.Plotly(click_submit_button=True)
# Define the plot function that will be called when the user selects their options
def plot_function(df, x, y):
fig = px.scatter(df, x=x, y=y)
return fig
# Create the Gradio interface
interface = gr.Interface(fn=main, inputs=inputs, outputs=outputs, title="CSV Plotter", plot=plot, plot_fn=plot_function)
interface.launch()