en
Feedback
NeuroCatalog | Каталог Нейросетей Нейросети | Midjourney | Промты | AI | Prompts | OpenAi | ChatGPT | Искусственный Интеллект

NeuroCatalog | Каталог Нейросетей Нейросети | Midjourney | Промты | AI | Prompts | OpenAi | ChatGPT | Искусственный Интеллект

Open in Telegram

Последние тренды в нейросетях и ИИ.

Show more
6 820
Subscribers
No data24 hours
-47 days
-14230 days
Posts Archive
Скрипт извлечение текста из PDF-файла Установить пакет pip install PyPDF2 # import module PyPDF2 import PyPDF2 # put 'example.pdf' in working directory # and open it in read binary mode pdfFileObj = open('example.pdf', 'rb') # call and store PdfFileReader # object in pdfReader pdfReader = PyPDF2.PdfFileReader(pdfFileObj) # to print the total number of pages in pdf # print(pdfReader.numPages) # get specific page of pdf by passing # number since it stores pages in list # to access first page pass 0 pageObj = pdfReader.getPage(0) # extract the page object # by extractText() function texts = pageObj.extractText() # print the extracted texts print(texts) Объединение двух файлов в один Копироуем текст из двух PDF-файлов и объединить его в новый PDF-файл. import PyPDF2 # open two pdfs pdf1File = open('example.pdf', 'rb') pdf2File = open('example2.pdf', 'rb') # read first pdf pdf1Reader = PyPDF2.PdfFileReader(pdf1File) # read second pdf pdf2Reader = PyPDF2.PdfFileReader(pdf2File) # for writing in new pdf file pdfWriter = PyPDF2.PdfFileWriter() for pageNum in range(pdf1Reader.numPages): pageObj = pdf1Reader.getPage(pageNum) pdfWriter.addPage(pageObj) for pageNum in range(pdf2Reader.numPages): pageObj = pdf2Reader.getPage(pageNum) pdfWriter.addPage(pageObj) # create new pdf 'example3.pdf' pdfOutputFile = open('example3.pdf', 'wb') pdfWriter.write(pdfOutputFile) pdfOutputFile.close() pdf1File.close() pdf2File.close() 👉