File size: 1,028 Bytes
37746c7
2928d72
 
 
 
 
 
 
 
 
 
 
 
 
37746c7
2928d72
37746c7
2928d72
 
 
37746c7
2928d72
37746c7
2928d72
 
 
 
 
 
 
 
 
37746c7
 
2928d72
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
28
29
30
31
32
33
34
35
36
import gradio as gr
import pandas as pd
from BHEL import parse_bhel_pdf
from FederalElectric import parse_federal_electric_pdf
from ALNISF import parse_alnisf_pdf

def process_pdf(file, format_type):
    # Select the appropriate parser based on format type
    if format_type == "BHEL.py":
        df = parse_bhel_pdf(file.name)
    elif format_type == "Federal Electric.py":
        df = parse_federal_electric_pdf(file.name)
    elif format_type == "AL-NISF":
        df = parse_alnisf_pdf(file.name)
    else:
        return "Unsupported format selected", None

    # Save the DataFrame to an Excel file
    output_file = f"{format_type}_Data.xlsx"
    df.to_excel(output_file, index=False)

    return output_file

# Gradio Interface
iface = gr.Interface(
    fn=process_pdf,
    inputs=[
        gr.File(label="Upload PDF"),
        gr.Dropdown(choices=["BHEL.py", "Federal Electric.py", "AL-NISF"], label="Select Format")
    ],
    outputs=gr.File(label="Download Excel")
)

if __name__ == "__main__":
    iface.launch()