DSatishchandra commited on
Commit
6168767
·
verified ·
1 Parent(s): 441222c

Update federal_electric.py

Browse files
Files changed (1) hide show
  1. federal_electric.py +16 -0
federal_electric.py CHANGED
@@ -109,6 +109,22 @@ def gradio_interface(pdf_file, output_format):
109
  output_file = process_and_save(pdf_file, output_format)
110
  return output_file
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  # Gradio app interface
113
  iface = gr.Interface(
114
  fn=gradio_interface,
 
109
  output_file = process_and_save(pdf_file, output_format)
110
  return output_file
111
 
112
+ def process_pdf(file):
113
+ try:
114
+ # Extract text from the PDF
115
+ text = extract_text_from_pdf(file)
116
+
117
+ # Process the extracted text into a DataFrame
118
+ df = extract_po_data(file.name)
119
+
120
+ # Save the DataFrame to an Excel file
121
+ output_path = "federal_electric_extracted_data.xlsx"
122
+ df.to_excel(output_path, index=False, engine="openpyxl")
123
+ return output_path, "Data extraction successful!"
124
+ except Exception as e:
125
+ return None, f"Error during processing: {str(e)}"
126
+
127
+
128
  # Gradio app interface
129
  iface = gr.Interface(
130
  fn=gradio_interface,