Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] add DataFrame to_excel params #169

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions camelot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ def _compress_dir(self, **kwargs) -> None:
filepath = os.path.join(dirname, filename)
z.write(filepath, os.path.basename(filepath))

def export(self, path, f="csv", compress=False):
"""Export the list of tables to specified file format.
def export(self, path, f="csv", compress=False, df_kwargs={}):
"""Exports the list of tables to specified file format.

Parameters
----------
Expand All @@ -855,6 +855,8 @@ def export(self, path, f="csv", compress=False):
File format. Can be csv, excel, html, json, markdown or sqlite.
compress : bool
Whether or not to add files to a ZIP archive.
df_kwargs : dict, optional (default: {})
A dict of `pandas.DataFrame.to_excel https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html`

"""
dirname = os.path.dirname(path)
Expand All @@ -874,7 +876,7 @@ def export(self, path, f="csv", compress=False):
writer = pd.ExcelWriter(filepath)
for table in self._tables:
sheet_name = f"page-{table.page}-table-{table.order}"
table.df.to_excel(writer, sheet_name=sheet_name)
table.df.to_excel(writer, sheet_name=sheet_name, **df_kwargs)
writer.close()
if compress:
zipname = os.path.join(os.path.dirname(path), root) + ".zip"
Expand Down
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
click>=6.7
matplotlib>=2.2.3
numpy>=1.13.3
opencv-python>=3.4.2.17
openpyxl>=2.5.8
pandas>=0.23.4
pdfminer.six>=20170720
PyPDF2>=1.26.0
XlsxWriter>=0.9.8