Home / GenAI Engineer practice test / Data Preparation / Question

Databricks Generative AI Engineer Associate · free practice question

A data scientist needs to retrieve text from numerous PDF documents that were created digitally and contain selectable text layers. A primary challenge in this…

Exam-style question on Data Preparation from the free GenAI Engineer practice test, with the answer and a full explanation below.

Updated November 11, 2026

Data Preparation

A data scientist needs to retrieve text from numerous PDF documents that were created digitally and contain selectable text layers. A primary challenge in this task is to ensure the correct reading order is maintained within pages that feature multi-column layouts, especially when dealing with content like financial reports that might combine two-column tables with single-column paragraphs. Which Python library provides the MOST effective solution for this specific requirement?

  1. APyPDF2, which uses each page's bounding box information to order the extracted text column by column in multi-column layouts
  2. Bpytesseract, which renders each page to an image and rebuilds the multi-column reading order from the recognized text blocks
  3. Cbeautifulsoup4, which parses the PDF opened in byte mode and uses its structural markers to rebuild the reading order
  4. Dpdfminer.six, which exposes per-character coordinates and font data that layout analysis uses to order columns
  5. Epandas, which loads the PDF through read_csv with a newline separator and treats each text line as a separate record
Answer & explanation

Correct answer: D

WHY D is correct: pdfminer.six is the Python PDF processing library that provides the most detailed access to PDF internal text positioning data. It exposes the X/Y coordinates, font size, and page layout objects for every character and text span in a PDF. This granular position data is what enables layout analysis — correctly determining which text belongs to the left column versus the right column by comparing X coordinates, and reconstructing the proper reading order within each column by Y coordinate. For multi-column PDFs, pdfminer.six's PDFPageAggregator with LAParams (layout analysis parameters) can be tuned to detect column boundaries and produce correctly-ordered text output. It is the industry-standard choice for layout-aware digital PDF text extraction.

WHY NOT A: PyPDF2 (now pypdf) extracts text by reading the PDF's internal content stream in the order the text objects were drawn, which often does not match reading order. For simple single-column PDFs this is acceptable, but for multi-column layouts, PyPDF2 frequently produces interleaved text from both columns (reads left-column line 1, right-column line 1, left-column line 2, right-column line 2) instead of completing the left column before moving to the right.

WHY NOT B: pytesseract applies OCR (optical character recognition) by converting PDF pages to images and running the Tesseract OCR engine. This is designed for scanned/image-based PDFs that have NO text layer. Using it on native digital PDFs introduces a quality regression — the re-rendering process can introduce OCR errors in text that was originally perfect digital text. It also does not natively perform layout analysis superior to pdfminer.

WHY NOT C: beautifulsoup4 is an HTML/XML parser. It cannot parse PDF binary format. PDFs use a proprietary binary format (not HTML), and opening a PDF as raw bytes and passing it to BeautifulSoup would produce no meaningful output.

WHY NOT E: pandas.read_csv() reads delimiter-separated value files. A PDF binary file is not a CSV and cannot be parsed by read_csv() in any mode. This is a nonsensical option designed to test basic knowledge of library purpose.

Take the full GenAI Engineer practice test free →

Would you pass today?

This question is one of 45 in the free, timed Databricks Generative AI Engineer Associate practice test. Take it and get a section-by-section score.

Start the free test →