Topic_modelling / app2.py
Alimubariz124's picture
Rename app.py to app2.py
b090e41 verified
raw
history blame contribute delete
650 Bytes
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()