Saturday, 16 November 2019

Camelot Pdf Extracion FAIL parsing

Im getting a problem with Camelot library

Im extracting data from PDF, my code is running "ok" for previous 23 page, but for this case its failing to parse text/table ending

I suppose the problem is the string is so long reaching table border

Also tried "stream" but got worst results

PDF Source Data

pdf

PDF Output LAYOUT

layout

My output parsed is like

"ALT4945\n24 V"
"70\/140 A   ALT5860\n12 V\n90 A"

Desired output should be

"ALT4945\n24 V 70\/140 A"
"ALT5860\n12 V\n90 A"

My first code that work correctly for previous page is

tables = camelot.read_pdf("CROSSREFERENCE.pdf", pages=wPAGES, flavor="lattice")

From the website Camelot Doc https://camelot-py.readthedocs.io/en/master/api.html I get that posible configuration on pdf parser.

"" PARAMS for lattice
line_scale  (default: 15)
copy_text   ((default: None))
shift_text  (default: ['l', 't'])
line_tol    (default: 2)
joint_tol   (default: 2)
threshold_blocksize   (default: 15)
threshold_constant    (default: -2)
iterations   (default: 0)
resolution   (default: 300)
"""

Then I get that problem, tried to solve "playing" with more params, but didnt found the winner

tables = camelot.read_pdf("CROSSREFERENCE.pdf", pages=wPAGES, flavor="lattice", split_text=True, resolution=720, line_scale=250, line_tol=3, joint_tol=3, threshold_blocksize=15)

tables = camelot.read_pdf("CROSSREFERENCE.pdf", pages=wPAGES, flavor="lattice", split_text=True, resolution=720, line_scale=250, line_tol=1, joint_tol=1, threshold_blocksize=3)

Can I get some advice about params to avoid that??

Thanks

edit1: PDF source : https://www.siom.it/images/catalogo-motorini-alter.pdf (Page 24)



from Camelot Pdf Extracion FAIL parsing

No comments:

Post a Comment