Spaces:
Runtime error
Runtime error
File size: 650 Bytes
9cb088e 0c22540 9cb088e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
import pandas as pd
# Function to load and preview CSV
def preview_csv(file):
if file is None:
return "No file uploaded."
try:
df = pd.read_csv(file.name,encoding='latin1')
return df.head() # Show the first 5 rows
except Exception as e:
return f"Error reading CSV: {e}"
# Gradio interface
iface = gr.Interface(
fn=preview_csv,
inputs=gr.File(label="Upload CSV File", file_types=[".csv"]),
outputs=gr.Dataframe(label="CSV Preview"),
title="CSV Preview App",
description="Upload a CSV file to see the first 5 rows."
)
if __name__ == "__main__":
iface.launch()
|