Reputation: 23
CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 'C:\Users\vijv2c13136\AppData\Local\Continuum\anaconda2\lib\site-packages\tabula\tabula-1.0.2-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'JSON', 'TONY.pdf']' returned non-zero exit status 2
When I try to print the tables in the .pdf file. It shows this particular error.
from tabula import wrapper
print(wrapper.read_pdf("TONY.pdf", multiple_tables=True,pages="all")
This is my code for table extraction of .pdf file. But, it shows the above error when I am trying to print.
Upvotes: 0
Views: 7287
Reputation: 923
No real need to use dataframes
, simply do:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axis('off')
ax.table(cellText=[
['row1', 'row1'],
['row2', 'row2']
],
colLabels=['col1', 'col2'],
loc='center')
fig.tight_layout()
plt.savefig("table.pdf", bbox_inches='tight')
Upvotes: 0
Reputation: 16772
One way to write the table in pandas dataframe and then save it. (even displayed it)
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
fig.patch.set_visible(False)
ax.axis('off')
ax.axis('tight')
df = pd.DataFrame(np.random.randn(10, 4), columns=list('ABCD'))
ax.table(cellText=df.values, colLabels=df.columns, loc='center')
fig.tight_layout()
plt.show()
plt.savefig("tablepdf.pdf", bbox_inches='tight')
Upvotes: 2