Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
import fitz # PyMuPDF
|
| 4 |
import pandas as pd
|
| 5 |
-
|
| 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
|
| 52 |
def main():
|
| 53 |
-
#
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 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 |
|
|
|