Last active
November 19, 2024 17:06
-
-
Save sdg-1/9203619987005e067afcdb5ca695a99f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pdfplumber | |
import PyPDF2 | |
# Open the PDF file with PyPDF2 | |
pdf_file = 'example.pdf' | |
pdf_reader = PyPDF2.PdfReader(pdf_file) | |
# Extract text with PyPDF2 | |
full_text = "" | |
for page in pdf_reader.pages: | |
full_text += page.extract_text() # Extract text from each page | |
print("Extracted Text:", full_text) | |
# Extract tables with pdfplumber | |
with pdfplumber.open(pdf_file) as pdf: | |
for page in pdf.pages: | |
tables = page.extract_tables() # Extract tables | |
for table in tables: | |
print("Extracted Table:", table) # Print each table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment