Spaces:
Runtime error
Runtime error
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() | |