Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
|
| 5 |
+
CSV_URL = "https://gardenstatemls.stats.showingtime.com/infoserv/s-v1/kpou-Asg"
|
| 6 |
+
|
| 7 |
+
# Function to fetch and plot CSV data
|
| 8 |
+
def plot_csv():
|
| 9 |
+
# Read CSV directly from URL
|
| 10 |
+
df = pd.read_csv(CSV_URL)
|
| 11 |
+
|
| 12 |
+
# Create a simple plot - adjust as needed based on CSV columns
|
| 13 |
+
plt.figure(figsize=(10, 6))
|
| 14 |
+
df.plot(x=df.columns[0], y=df.columns[1:], marker='o')
|
| 15 |
+
plt.title("CSV Data Plot")
|
| 16 |
+
plt.xlabel(df.columns[0])
|
| 17 |
+
plt.ylabel("Values")
|
| 18 |
+
plt.grid(True)
|
| 19 |
+
plt.tight_layout()
|
| 20 |
+
|
| 21 |
+
# Save the plot to a file
|
| 22 |
+
plt.savefig("plot.png")
|
| 23 |
+
plt.close()
|
| 24 |
+
|
| 25 |
+
return "plot.png"
|
| 26 |
+
|
| 27 |
+
# Gradio Interface
|
| 28 |
+
demo = gr.Interface(
|
| 29 |
+
fn=plot_csv,
|
| 30 |
+
inputs=[],
|
| 31 |
+
outputs=gr.Image(type="filepath"),
|
| 32 |
+
title="CSV Plotter",
|
| 33 |
+
description="This Space downloads the CSV from GSMLS"
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
demo.launch(debug=True)
|