Databricks Generative AI Engineer Associate Question 60
Single answerYou are building a pipeline in Databricks to process a collection of PDF documents and extract their textual content for use in a generative AI model. Which Python package would be most appropriate for this task?
- A
PyPDF2
- B
BeautifulSoup
- C
Pandas
- D
OpenCV
Show answer and explanation
Correct answer: A
Explanation
To extract text from PDF documents, PyPDF2 is the most appropriate Python package. It is specifically tailored for handling PDF files and includes methods for extracting textual content, making it ideal for integrating into a pipeline for generative AI models.
- A. Correct.
PyPDF2 is a Python library specifically designed for working with PDF files, including extracting text from them. It is the most suitable package for this use case.
- B. Incorrect.
BeautifulSoup is used for parsing and extracting data from HTML and XML documents, not PDFs. It is not appropriate for this task.
- C. Incorrect.
Pandas is a data analysis library used for handling structured data, such as CSVs or databases. It does not provide tools for extracting text from PDF documents.
- D. Incorrect.
OpenCV is a computer vision library for image processing and machine learning tasks. While it can handle image-based PDFs in some advanced scenarios, it is not designed for standard PDF text extraction.