awacke1's picture
Update app.py
77a9e5b
import gradio as gr
import pandas as pd
import plotly.express as px
# Create a function to write the CSV file
def write_csv(record_count, topic, intervention):
df = pd.DataFrame({
"RecordCount": [record_count],
"Topic": [topic],
"Intervention": [intervention]
})
df.to_csv("testfile.csv", index=False, mode='a')
# Create a function to plot the data from the CSV file
def plot_data():
df = pd.read_csv("testfile.csv")
fig = px.scatter(df, x="RecordCount", y="Intervention", color="Topic")
return fig
# Define the inputs for the Gradio interface
inputs = [
gr.inputs.Slider(label="Record Count", minimum=0, maximum=100, default=50),
gr.inputs.Textbox(label="Topic"),
gr.inputs.Textbox(label="Intervention")
]
# Define the outputs for the Gradio interface
outputs = [
gr.Plot(plot_data),
gr.Textbox(label="Data written to testfile.csv")
]
# Create the Gradio interface
interface = gr.Interface(write_csv, inputs, outputs, title="Record Plotter")
# Launch the Gradio interface
interface.launch()