data-explorer / app.py
jasvir-singh1021's picture
Update app.py
18e96cf verified
raw
history blame
544 Bytes
from datasets import load_dataset
from tabulate import tabulate
import gradio as gr
# Load CSV as Hugging Face Dataset
def view_data():
dataset = load_dataset("csv", data_files="sample_data.csv")["train"]
table = tabulate(dataset[:5], headers="keys", tablefmt="github")
return table
with gr.Blocks() as demo:
gr.Markdown("### ๐Ÿ“Š Sample Dataset Viewer")
view_btn = gr.Button("View First 5 Rows")
output = gr.Textbox(label="Dataset Preview", lines=10)
view_btn.click(view_data, outputs=output)
demo.launch()