PDF & Image to CSV Table Extractor
github.com/vitali84/pdf-to-csv-table-extactor- Category
- Developer Tools
- Rank
- No. 1273Tools index
- Pricing
- Open Source
- Type
- TOOL
- GitHub
- 141 stars
- Latest release
- v1.0.0
- Date
About
A Python library and command-line tool that extracts tables from PDFs and images and writes them to CSV, Markdown, JSON or DataFrames. It groups tables with matching columns into separate CSV files. Digital PDFs use the embedded text layer, and scans fall back to RapidOCR. Everything runs locally with no cloud calls once models are cached.
What it does
Point it at a report, a scanned page or a folder of photographed pages and it finds every ruled grid with computer-vision line detection, then fills each cell with words. On born-digital documents those words come straight from the file's own character positions, so there is nothing to misread. On scans, an on-device recognition model reads them instead. A final pass stitches a table that spans several pages back together, dropping repeated header rows and matching headerless continuation pages by column layout and data type.
Why it's ranked here
It goes after the dull failure that sinks most extraction jobs: a long report whose table runs across dozens of pages, with headers repeated on some and missing on others. That merge is automatic here and marked manual for all four alternatives in the project's own comparison. MIT licensed, installable from PyPI with no Java, Ghostscript or Tesseract on the machine, typed, and usable as a command line or an importable library. The speed figures and the comparison table are the author's own measurements, so the case rests on the design rather than the numbers.
What's good
The choice between real text and recognition is made per page, so a digital report with a stamped scan inside it gets both treatments without a flag. The recognition model only loads when some page needs it, which keeps a purely digital run light. Detection thresholds are written down and commented, including a gray cutoff picked so pale table borders still register. Extraction engines sit behind a small swappable interface, a debug mode draws the detected header and cells over each page image, and an option adds a byte-order mark for Excel compatibility.
Tradeoffs
Grid finding rests on fixed pixel rules: a candidate needs at least six line crossings and a divider must cover 35% of the row or column, so faint, broken or hand-drawn rules can lose a table, and unruled tables depend on a separate whitespace-alignment pass. NVIDIA acceleration is not an install option; you uninstall the CPU runtime and install the GPU build by hand. Right-to-left script support sits in an optional extra because its shaping library is LGPL, which matters if you ship this inside a product. The sample files behind the headline examples are left out of the PyPI package.
How to use it well
Reach for it in batch jobs that turn government reports, statements or scanned forms into spreadsheet rows you load elsewhere, especially when one table runs across many pages. Run the doctor command first to see which accelerators and language packs are present, and pre-install language packs if the machine will be offline. Turn on the debug overlay for the first few documents of a new layout and check the detected cells before trusting a batch. The GitHub repository name is spelled extactor while the package is extractor. It does not convert prose, charts or whole documents to Markdown; pick a document converter for that.
Technical notes+
src/pdf_table_extractor/pipeline.py validates text_source (auto, ocr, native) and workers, resolves the accelerator, loads pages with native text extraction unless text_source is ocr, and counts OCR candidate pages so resolve_rapidocr_config runs only when at least one page lacks native tokens. It takes a parallel batch path through OpenCVBackend.extract_pages when the resolved worker count exceeds one, otherwise pops pages one at a time so raster bitmaps are released as it goes, then calls group_tables and optionally save_debug_overlays. src/pdf_table_extractor/cv_tables.py builds line masks from adaptive plus Otsu thresholding gated by gray < 238, opens with kernels of max(25, 4% of width) horizontally and max(20, 2% of height) vertically, labels connected grid components, rejects ROIs under 60x30 px or with fewer than 6 joints, keeps dividers whose projection covers 35%, drops cells thinner than 10 px, infers horizontal merges from missing vertical dividers, and discards grids contained in a larger one within 5 px. Borderless detection only runs on tokens outside bordered grids and needs at least 6 of them. src/pdf_table_extractor/backends/base.py defines the TableExtractionBackend protocol (a name plus extract per page) and compute_column_x_spans used for cross-page column matching. pyproject.toml pins Python >=3.11,<3.15, builds with hatchling, exposes three console scripts pointing at the same main, sets mypy disallow_untyped_defs, and lists python-bidi under the rtl extra with a comment citing its LGPL license. docs/cli.md documents merge modes schema, none and all.
Observed
- License
- MIT (LICENSE, declared in pyproject.toml)
- Language
- Python, requires 3.11 through 3.14
- Install surface
- PyPI package installable with pip, uv or uvx; optional rtl extra
- Interfaces
- CLI under three equivalent command names, plus a Python library entry point
- Text source
- PDFium native text layer per page, RapidOCR on ONNX Runtime as fallback
- Accelerators
- CPU, NVIDIA CUDA and AMD ROCm via a device flag; CUDA needs a manual onnxruntime-gpu swap
- External binaries
- None required: no Java, Ghostscript, Tesseract or Poppler in the dependency list
- Optional dependency license
- rtl extra installs python-bidi, which pyproject.toml notes is LGPL
- Typing
- Typing :: Typed classifier; mypy configured with disallow_untyped_defs
- Extensibility
- Pluggable extraction backend protocol in src/pdf_table_extractor/backends/base.py and installable OCR language packs
Read from README.md, pyproject.toml, docs/cli.md, src/pdf_table_extractor/pipeline.py, src/pdf_table_extractor/cv_tables.py, src/pdf_table_extractor/backends/base.py, LICENSE.
Similar tools
Tags
Tech Stack
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.