Commit Graph

15 Commits

Author SHA1 Message Date
Jeremy Singer-Vine 6f6b465260 Add .curve_edges, use by default in table-detect.
Most of the groundwork was already there to add a PDF/Page.curve_edges
property. And, inspired, by
https://github.com/jsvine/pdfplumber/discussions/858 and related issues,
we now include 0/90/180/270-degree oriented curve segments into the
default table-detection strategy. As before, you can still switch to the
"lines_strict" to use only lines defined as such (rather than also using
rect and curve edges).
2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine c4e1b294bb Allow *all* extract_text kwargs for tables
Any `text_`-prefixed table extraction setting now automatically gets
passed to `.extract_text(...)` via `table.extract(...)`.

This introduces one minor but breaking change, which is that
`keep_blank_chars` (previously, a valid table extraction setting) now
needs to be passed as `text_keep_blank_chars`.
2023-02-13 17:51:33 -05:00
Jeremy Singer-Vine 9587cc7d22 Add type annotations and refactor accordingly
A fairly large commit, adding type annotations/hints to the entire
library, and refactoring the library accordingly.

Most of the refactoring changes should have no practical effect on
usage, but several others are notable:

- Added `TableSettings` class, a behind-the-scenes handler for managing
  and validating table-extraction settings.
- Renamed the positional argument to `.to_csv(...)` and `.to_json(...)`
  from `types` to `object_types`.
- Tweaked the output of `.to_json(...)` so that, if an object type is
  not present for a given page, it has no key in the page's object
  representation.
- Removed `utils.filter_objects(...)` and move the functionality to
  within the `FilteredPage.objects` property calculation, the only part
  of the library that used it.
- Removed code that sets `pdfminer.pdftypes.STRICT = True` and
  `pdfminer.pdfinterp.STRICT = True`, since that [has now been the
  default for a
  while](https://github.com/pdfminer/pdfminer.six/commit/9439a3a31a347836aad1c1226168156125d9505f).
2022-05-06 09:43:50 -04:00
Jeremy Singer-Vine d72b879665 Enforce import order via isort 2021-12-16 22:22:54 -05:00
Jeremy Singer-Vine aa2d594d3b Raise error if certain table-ex. settings negative 2021-12-03 17:46:59 -05:00
samkit-jain 608db0225c Fix bug that crashed table extraction when null value provided for (text|intersection)_(x|y)_tolerance keys
Fixes #539
Thanks to @yoavxyoav for reporting
2021-11-22 19:53:03 +05:30
bobluda 6cea72da22 Add test and pdf for mixed strategy table extraction 2021-07-11 23:59:27 +02:00
Jeremy Singer-Vine 83dd31f7dc Add test for extract_table(s) re. text extraction 2021-05-08 17:42:12 -04:00
Samkit Jain a17c5a72b6 Sort tables extracted on a page by their top position
Fixes #336
h/t @gqh1995 for reporting
2021-01-21 20:05:29 +05:30
Jeremy Singer-Vine b4b0282730 Make tests flake8-compatible 2020-12-16 22:29:51 -05:00
Jeremy Singer-Vine 5c62be2e16 Format all tests with psf/black 2020-12-16 22:19:17 -05:00
Jeremy Singer-Vine f665863daf Fix test_table.py ValueError tests
They were erroring on wrong aspect, because PDF object was being passed
instead of Page object.
2020-10-20 09:42:23 -04:00
Jeremy Singer-Vine bc407790f1 Decimalize "simple" explicit_h/v_lines descs (#290)
... in TableFinder. This way, you can pass ints/floats without
pre-converting them to Decimal objects.
2020-10-20 09:41:49 -04:00
Jeremy Singer-Vine a5e7d7fa52 Remove pandas from dev requirements and tests
Results in needing one more # pragma: nocover statement, but on a
simple line of code. See PR #253 for details and motivation.
2020-08-15 12:03:34 -04:00
Jeremy Singer-Vine 3f4b4b24b3 Bring pdfplumber/table.py coverage to 100% 2020-08-06 22:19:40 -04:00