TaxDirection / app.py
SantanuBanerjee's picture
Update app.py
e4d07f2 verified
raw
history blame
896 Bytes
import gradio as gr
import pandas as pd
def process_excel(file):
try:
# Ensure the file path is correct
file_path = file.name if hasattr(file, 'name') else file
# Read the Excel file
df = pd.read_excel(file_path)
# Perform any processing on the DataFrame here
return df.head() # Return the first few rows as an example
except Exception as e:
return str(e) # Return the error message
# Define the Gradio interface
interface = gr.Interface(
fn=process_excel, # The function to process the uploaded file
inputs=gr.File(type="filepath", label="Upload Excel File"), # File upload input
outputs="dataframe", # Display the output as a DataFrame
title="Excel File Uploader",
description="Upload an Excel file to see the first few rows."
)
# Launch the interface
if __name__ == "__main__":
interface.launch()