Awesome, so helpful! That's much simpler and ready-to-use compared to all others approaches found online. Is there a way to export the extracted text to a csv or xlsx file?
The code did not work for me on a Windows 11 PC. I kept having ChatGPT analyze the code and error messages and after many tires it fixed it: import os import PyPDF2 import re import math def extract_text_from_pdf(pdf_file: str) -> [str]: # Open the PDF file of your choice with open(pdf_file, 'rb') as pdf: reader = PyPDF2.PdfReader(pdf) pdf_text = [] for page in reader.pages: content = page.extract_text() pdf_text.append(content) return pdf_text def main(): extracted_text = extract_text_from_pdf('sample.pdf') for text in extracted_text: print(text) if __name__ == '__main__': main()
Thank you for the awesome tutorial. I have a some question about extracting articles. I hope you can help me. While extracting articles and reports there are many references and table legends, titles which is not required. Would it be possible to remove all those references and table contents including legends and titles when extracting the pdf file?
Hey , I have some 600 files which have large volume of data, text extraction using pypdf2 is taking a lot of time , is there any other way to do this ?
I am pretty sure there are over a thousand isntances of the word "coffee" in the pdf. However, this seems to have only counted the number of pages that the word appeared.
I found that by opening a pdf file with Mozilla Firefox and inspecting it with the developer tools you can collect its text (with the help of JavaScript) after the web browser has converted it to HTML and maybe save it for further processing with someone programming language.
I wrote the code line per line, word for word but it continue to give me File not found, how it's possible? p.s. I managed to extrat text, the only problem is the layout of the answer, i have a string long miles
def convert_pdf_to_text(pdf_path): with pdfplumber.open(pdf_path) as pdf: for page in pdf.pages: text = page.extract_text(layout=True) print(text) return text
In some of the latest updates to PyPDF2 the class "PdfFileReader" got replaced with "PdfReader". Code still works fine with "PdfReader". :)
Awesome, so helpful! That's much simpler and ready-to-use compared to all others approaches found online. Is there a way to export the extracted text to a csv or xlsx file?
Just amazing explanation, short and sweet!
It's so helpful...loved it ❤
Glad it helped! :)
The code did not work for me on a Windows 11 PC. I kept having ChatGPT analyze the code and error messages and after many tires it fixed it:
import os
import PyPDF2
import re
import math
def extract_text_from_pdf(pdf_file: str) -> [str]:
# Open the PDF file of your choice
with open(pdf_file, 'rb') as pdf:
reader = PyPDF2.PdfReader(pdf)
pdf_text = []
for page in reader.pages:
content = page.extract_text()
pdf_text.append(content)
return pdf_text
def main():
extracted_text = extract_text_from_pdf('sample.pdf')
for text in extracted_text:
print(text)
if __name__ == '__main__':
main()
Thanks !
Thank you so fucking much i got crazy over this
Thanks a lot mate!
It worked! Thank you !!
Thank you for the awesome tutorial. I have a some question about extracting articles. I hope you can help me. While extracting articles and reports there are many references and table legends, titles which is not required. Would it be possible to remove all those references and table contents including legends and titles when extracting the pdf file?
Thanks for the awesome tutorial. Please do the video for two sided pdfs. Which wasnt there on youtube🙃
Will it work on Arabic language and will it be able to extract hand written manuscript?
How to extract data from more than one PDF file and put it in a table
Got an answer?
Hey , I have some 600 files which have large volume of data, text extraction using pypdf2 is taking a lot of time , is there any other way to do this ?
Nice tutorial, how can i get the cordinates of the text in my pdf file?
great as always.
I keep on getting Syntax Error: unmatched ')' on line 4 I'm running python 3.9 could that be the case?
Excellent
helped me a lot. Thanks
what if we want to extract text for any particular page
I am pretty sure there are over a thousand isntances of the word "coffee" in the pdf. However, this seems to have only counted the number of pages that the word appeared.
Do you have any solution for pdfs with characters because when I try to apply this solution on those pdfs it prints gibberish characters.
U r awesome 👏
Thanks! :)
Hi sir..is it Work on Local Language Like Telugu
Thank you bro
Great
I found that by opening a pdf file with Mozilla Firefox and inspecting it with the developer tools you can collect its text (with the help of JavaScript) after the web browser has converted it to HTML and maybe save it for further processing with someone programming language.
I wrote the code line per line, word for word but it continue to give me File not found, how it's possible?
p.s. I managed to extrat text, the only problem is the layout of the answer, i have a string long miles
def convert_pdf_to_text(pdf_path):
with pdfplumber.open(pdf_path) as pdf:
for page in pdf.pages:
text = page.extract_text(layout=True)
print(text)
return text
how do you add the pdf file to the project?
So this is not an OCR
this only extracted text from the first page of my PDF. anyone else have this issue?
Thanks for the video!
please the resolution of your screen is not clear
Just change the resolution on RUclips from 144p to 720p
no idea how this is setup kina pointless where is pypdf do i get it from inside my bum bum? and what is this program?
pip install pypdf