DSatishchandra's picture
Update app.py
2928d72 verified
raw
history blame
1.03 kB
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()