Skip to content

Commit

Permalink
Decimalize "simple" explicit_h/v_lines descs (#290)
Browse files Browse the repository at this point in the history
... in TableFinder. This way, you can pass ints/floats without
pre-converting them to Decimal objects.
  • Loading branch information
jsvine committed Oct 20, 2020
1 parent 9cf1591 commit bc40779
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pdfplumber/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ def get_edges(self):
else:
v_explicit.append(
{
"x0": desc,
"x1": desc,
"x0": utils.decimalize(desc),
"x1": utils.decimalize(desc),
"top": self.page.bbox[1],
"bottom": self.page.bbox[3],
"height": self.page.bbox[3] - self.page.bbox[1],
Expand Down Expand Up @@ -520,8 +520,8 @@ def get_edges(self):
"x0": self.page.bbox[0],
"x1": self.page.bbox[2],
"width": self.page.bbox[2] - self.page.bbox[0],
"top": desc,
"bottom": desc,
"top": utils.decimalize(desc),
"bottom": utils.decimalize(desc),
"orientation": "h",
}
)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ def test_edges_strict(self):
""
]

def test_explicit_desc_decimalization(self):
"""
See issue #290
"""
tf = table.TableFinder(self.pdf.pages[0], {
"vertical_strategy": "explicit",
"explicit_vertical_lines": [ 100, 200, 300 ],
"horizontal_strategy": "explicit",
"explicit_horizontal_lines": [ 100, 200, 300 ],
})
assert tf.tables[0].extract()

def test_text_without_words(self):
assert table.words_to_edges_h([]) == []
assert table.words_to_edges_v([]) == []

0 comments on commit bc40779

Please sign in to comment.