Skip to content

Commit 47e78f4

Browse files
committed
Test for GitHub issue #585.
This test checks that Camelot can successfully extract tables when using the 'network' flavor with specified 'table_areas' and 'columns', ensuring that at least one table is detected.
1 parent 6b7b67d commit 47e78f4

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

tests/files/good_energy.pdf

125 KB
Binary file not shown.

tests/test_network.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,62 @@ def test_network_no_infinite_execution(testdir):
155155
)
156156

157157
assert len(tables) >= 1
158+
159+
160+
# Reported as https://github.com/camelot-dev/camelot/issues/585
161+
def test_issue_585(testdir):
162+
"""Test for GitHub issue #585.
163+
164+
This test checks that Camelot can successfully extract tables when using
165+
the 'network' flavor with specified 'table_areas' and 'columns',
166+
ensuring that at least one table is detected.
167+
168+
Parameters
169+
----------
170+
testdir : str
171+
The path to the test directory.
172+
173+
"""
174+
filename = os.path.join(testdir, "multiple_tables.pdf")
175+
tables = camelot.read_pdf(
176+
filename,
177+
flavor="network",
178+
table_areas=["100,700,500,100"],
179+
columns=["150,200,250,300,350,400,450,500"],
180+
)
181+
assert len(tables) > 0
182+
183+
def test_issue_585_network_flavor_with_table_areas(testdir):
184+
"""Test for GitHub issue #585, focusing on the 'network' flavor.
185+
186+
This test verifies that Camelot's 'network' flavor can detect and
187+
extract a table when a specific 'table_areas' is provided. The issue
188+
reported that this scenario was failing, while the 'lattice' flavor
189+
worked. This test ensures the 'network' flavor now behaves as expected.
190+
191+
It checks that exactly one table is found in the specified area.
192+
193+
Parameters
194+
----------
195+
testdir : str
196+
The path to the test directory, provided by the testing framework.
197+
This directory should contain the 'issue_585.pdf' file.
198+
199+
"""
200+
# Use the PDF file mentioned in the GitHub issue
201+
filename = os.path.join(testdir, "good_energy.pdf")
202+
203+
# The table_areas and columns are taken directly from the issue report
204+
# to replicate the exact conditions.
205+
tables = camelot.read_pdf(
206+
filename,
207+
flavor="network",
208+
table_areas=["46,213,558,180"],
209+
columns=["92,159,262,357,454,534"],
210+
split_text=True,
211+
)
212+
213+
# The core of the issue was that no tables were being detected.
214+
# This assertion now checks that exactly one table is found.
215+
assert len(tables) == 1
216+

0 commit comments

Comments
 (0)