| import gradio as gr | |
| import pandas as pd | |
| # Function to read CSV and return its content | |
| def read_csv(file): | |
| # Read the CSV file using pandas | |
| df = pd.read_csv(file.name) | |
| return df | |
| # Create the Gradio interface | |
| interface = gr.Interface( | |
| fn=read_csv, | |
| inputs=gr.File(label="Upload CSV File", type="filepath"), # Corrected type to 'filepath' | |
| outputs="dataframe", # Display the content as a dataframe | |
| title="CSV Viewer", | |
| description="Upload a CSV file, and the app will display its content." | |
| ) | |
| # Launch the interface | |
| interface.launch() | |