[REF] add DataFrame to_excel params, update requirements.txt since Pandas needs XlsxWriter>=0.9.8
parent
7d4c9e53c6
commit
27c3a41a46
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue