File size: 896 Bytes
76bfb75
bddf29f
 
 
e4d07f2
 
 
 
 
 
 
 
 
bddf29f
 
 
 
1a5796d
bddf29f
 
 
76bfb75
 
bddf29f
76bfb75
e4d07f2
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
26
27
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()