liveBook · Manning

Table extraction

As explained in The Well-Grounded Data Analyst

The process of recovering tabular rows and columns from a document or other source.

Table extraction recovers structured rows and columns from PDFs for analysis. The practical choice depends on file volume, automation needs, cost, privacy, and setup effort. section 5.4.2

A pragmatic extraction workflow is:

  • Define the tables and fields needed before choosing a method. section 5.4.2
  • Compare manual copying, dedicated extraction tools, and capabilities in the existing toolkit. section 5.4.2
  • Use pdfplumber to find page tables, convert extracted lists into pandas DataFrames, and reshape columns or rows as needed. section 5.4.2
  • Combine yearly tables, verify expected row counts, and export the resulting data to CSV. section 5.4.2

Extracting tables from selected pages

Open a PDF with pdfplumber, call find_tables() for each selected page, convert each result to a DataFrame using the first row as headers, and collect the tables. section 5.4.2

Table 5.1 Comparing PDF extraction techniques
Option
Pros
Cons
Manually copying data from PDFs into Excel
• Quick for a small amount of data
• Cannot be automated
• Does not scale to more data
Dedicated PDF extraction tool, either web or desktop based
• Likely to be accurate
• Web-based tool requires no installation
• May not be free
• Privacy concerns if uploading files to the web
• Hard to automate
• May not scale to multiple files
Finding PDF capabilities in our current tool
• Allows automation and scales to many files
• No need to leave/change our preferred tools
• Current toolkit may not have such capabilities
• If there are few files and a one-off task, it might be quicker to extract data manually.

Compare speed, accuracy, automation, scalability, installation, cost, and privacy across extraction approaches. section 5.4.2

How The Well-Grounded Data Analyst covers it

How deep it goes
Explains method selection, page-level extraction, DataFrame reshaping, consolidation, row checks, and CSV export.
Examples
Uses yearbook admissions, genre, and distributor tables extracted from selected PDF pages and combined across years.
What it assumes
Assumes PDF files and a Python environment with pandas and pdfplumber available.
What you can do after
Apply it via pdfplumber and pandas to extract, reshape, verify, combine, and export PDF tables.
How it connects
Connects PDF extraction with pandas DataFrames, Python libraries, automation, data validation, and CSV export.

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Data Analyst. The section links point to the parts of the book it draws on.