pull/142/merge
Nguyễn Xuân Bình 2020-05-05 08:13:56 +00:00 committed by GitHub
commit 51909a886f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -712,7 +712,7 @@ class TableList(object):
filepath = os.path.join(dirname, filename) filepath = os.path.join(dirname, filename)
z.write(filepath, os.path.basename(filepath)) z.write(filepath, os.path.basename(filepath))
def export(self, path, f="csv", compress=False): def export(self, path, f="csv", compress=False, df_kwargs={}):
"""Exports the list of tables to specified file format. """Exports the list of tables to specified file format.
Parameters Parameters
@ -723,6 +723,8 @@ class TableList(object):
File format. Can be csv, json, excel, html and sqlite. File format. Can be csv, json, excel, html and sqlite.
compress : bool compress : bool
Whether or not to add files to a ZIP archive. Whether or not to add files to a ZIP archive.
df_kwargs : dict, optional (default: {})
A dict of `pandas.DataFrame.to_excel https://github.com/pandas-dev/pandas/blob/master/pandas/core/generic.py#L1924`
""" """
dirname = os.path.dirname(path) dirname = os.path.dirname(path)
@ -742,7 +744,7 @@ class TableList(object):
writer = pd.ExcelWriter(filepath) writer = pd.ExcelWriter(filepath)
for table in self._tables: for table in self._tables:
sheet_name = "page-{}-table-{}".format(table.page, table.order) sheet_name = "page-{}-table-{}".format(table.page, table.order)
table.df.to_excel(writer, sheet_name=sheet_name, encoding="utf-8") table.df.to_excel(writer, sheet_name=sheet_name, encoding="utf-8", **df_kwargs)
writer.save() writer.save()
if compress: if compress:
zipname = os.path.join(os.path.dirname(path), root) + ".zip" zipname = os.path.join(os.path.dirname(path), root) + ".zip"

View File

@ -6,3 +6,4 @@ openpyxl>=2.5.8
pandas>=0.23.4 pandas>=0.23.4
pdfminer.six>=20170720 pdfminer.six>=20170720
PyPDF2>=1.26.0 PyPDF2>=1.26.0
XlsxWriter>=0.9.8