jithenderchoudary commited on
Commit
40ad815
·
verified ·
1 Parent(s): 6a1b2e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -13
app.py CHANGED
@@ -2,7 +2,7 @@
2
 
3
  import fitz # PyMuPDF
4
  import pandas as pd
5
- from tkinter import Tk, filedialog
6
 
7
  # Define function to extract table data from PDF
8
  def extract_data_from_pdf(pdf_path, start_pos, end_pos):
@@ -48,18 +48,14 @@ def extract_data_from_pdf(pdf_path, start_pos, end_pos):
48
  df = pd.DataFrame(data)
49
  return df
50
 
51
- # Main function with file picker dialog
52
  def main():
53
- # Use Tkinter file dialog to select the PDF file
54
- Tk().withdraw() # Close the root window
55
- pdf_path = filedialog.askopenfilename(
56
- title="Select PDF file",
57
- filetypes=[("PDF files", "*.pdf")]
58
- )
59
-
60
- # Ensure a file was selected
61
- if not pdf_path:
62
- print("No file selected. Exiting.")
63
  return
64
 
65
  # Define the range of SI No to extract
@@ -77,4 +73,3 @@ def main():
77
  if __name__ == "__main__":
78
  main()
79
 
80
-
 
2
 
3
  import fitz # PyMuPDF
4
  import pandas as pd
5
+ import os
6
 
7
  # Define function to extract table data from PDF
8
  def extract_data_from_pdf(pdf_path, start_pos, end_pos):
 
48
  df = pd.DataFrame(data)
49
  return df
50
 
51
+ # Main function to handle file input
52
  def main():
53
+ # Prompt user for PDF file path
54
+ pdf_path = input("Please enter the path to the PDF file: ")
55
+
56
+ # Check if the file exists
57
+ if not os.path.isfile(pdf_path):
58
+ print(f"Error: File '{pdf_path}' not found.")
 
 
 
 
59
  return
60
 
61
  # Define the range of SI No to extract
 
73
  if __name__ == "__main__":
74
  main()
75