Spaces:
Runtime error
Runtime error
File size: 1,037 Bytes
c051cf9 7681031 331fc60 c051cf9 7681031 331fc60 23d889a 331fc60 23d889a c051cf9 2659c0a 80b61aa c051cf9 |
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 parse_perfect_metaprint import parse_perfect_metaprint
from parse_toshiba import parse_toshiba_pdf
from parse_bhel import parse_bhel_pdf
def process_pdf(file, format_type):
# Select the appropriate parser based on format type
if format_type == "Perfect Meta Print":
df = parse_perfect_metaprint(file.name)
elif format_type == "Toshiba":
df = parse_toshiba_pdf(file.name)
elif format_type == "BHEL":
df = parse_bhel_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=["Perfect Meta Print", "Toshiba", "BHEL"], label="Select Format")
],
outputs=gr.File(label="Download Excel")
)
if __name__ == "__main__":
iface.launch()
|