-
Notifications
You must be signed in to change notification settings - Fork 0
/
OCR_basic
36 lines (24 loc) · 869 Bytes
/
OCR_basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""
Disclaimer: I do not remember where I picked this info, if it was a tutorial or just some documentation
pip install PyPDF2 pytesseract
pip install ghostscript
pip install poppler - no es necesairo
pip install tabula-py
"""
import PyPDF2
import pytesseract
from PIL import Image
from pdf2image import convert_from_path
mypath= "C:/Users/User/OneDrive/Desktop/Items_from_Psychometric_Tests_as_Training_Data_for.pdf"
pdf_file = open(mypath, 'rb')
pdf_reader = PyPDF2.PdfReader(pdf_file)
text_content = []
for page in pdf_reader.pages:
text_content.append(page.extract_text())
text_content= []
for page in pdf_reader.pages:
text_content = ' '.join(page.extract_text() for page in pdf_reader.pages)
pdf_file.close()
with open('prueba-readpdf.txt', 'w', encoding='utf-8') as txt_file:
for content in text_content:
txt_file.write(content)