Reputation: 1
i use to camelot with python to capture the content in PDF file. use
content1 = camelot.read_pdf(file2, flavor='stream', table_areas=['30,311,297,251'],strp_text = '\n')
content2 = camelot.read_pdf(file2, flavor='stream', table_areas=['315,309,585,250'], strp_text = '\n')
content3 = camelot.read_pdf(file2, flavor = 'stream', table_areas=['13,249,583,124'], strip_text = '\n')
that code works well.But i have want to capture 3 rectangles table range. But as the files are diffents which content has more and will change the table range more bigger than standard table1 table2
my issue is how do i capture the 3 rectangeles table dynamic based on file?
i consider to get the conntciont point axes in the via matplotlib, then put in camelot table range to set teh read range, to get teh axes, i have try this
#tables2 comes from file2
ieline1 = camelot.plot(tables2[0], kind='line')
ax = ieline1.axes[0]
lines = ax.lines
for line in lines:
x, y = line.get_xydata().T
print(x)
print(y)
result is like this , the result is looks like far away from my above picture show which i use manual set Axes. Any suggestions? thanks
[29.7638 29.7638]
[ 44.62762999 102.21166868]
[584.23459032 584.23459032]
[ 44.86756348 178.51051995]
[584.47462097 584.47462097]
[179.47025393 311.67360943]
[582.55437581 582.55437581]
[ 44.62762999 311.91354293]
[314.68017581 314.68017581]
[248.57110036 311.91354293]
[297.638 297.638]
[248.57110036 311.91354293]
[29.7638 29.7638]
[248.57110036 311.91354293]
[12.72162419 12.72162419]
[ 44.62762999 311.91354293]
[ 12.2415629 584.71465161]
[45.34743047 45.34743047]
[ 12.2415629 583.0344371]
[101.97173519 101.97173519]
[ 12.2415629 583.0344371]
[124.76541717 124.76541717]
[ 12.2415629 583.0344371]
[249.29090085 249.29090085]
[ 12.2415629 583.0344371]
[311.67360943 311.67360943]
[185.54368871 392.69013548]
[342.86496372 342.86496372]
[185.54368871 392.69013548]
[345.74416566 345.74416566]
type the code
#tables2 comes from file2
ieline1 = camelot.plot(tables2[0], kind='line')
ax = ieline1.axes[0]
lines = ax.lines
for line in lines:
x, y = line.get_xydata().T
print(x)
print(y)
but coudln't get my resut
Upvotes: 0
Views: 33