I have a code where I am using tabula-py
to read tables from pdf and then write the resulting list of dataframes
to a single excel with each dataframe
in a separate sheet.
Here is my current code:
def read_pdf(pdf_file):
output_filepath = "output.xlsx"
dfs = tabula.read_pdf(pdf_file, pages='all')
for i in range(len(dfs)):
print(dfs[i].to_string())
with ExcelWriter(output_filepath) as writer:
dfs[i].to_excel(writer, sheet_name='sheet%s' % i)
With the print function I can see dataframes
with values, but the resulting excel is empty with just one sheet and no output in it.