Skip to content

Commit

Permalink
User Control on Indices in the output (#34)
Browse files Browse the repository at this point in the history
* User control over indices in the output with `indexing`

* v2.1.2

* User control over indices in the output with `indexing`
  • Loading branch information
akshowhini authored Nov 6, 2020
1 parent b9622f6 commit c48fe70
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ExtractTable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,12 @@ def process_file(
result = ConvertTo(server_response=trigger_resp, output_format=output_format, indexing=indexing).output
return result

def save_output(self, output_folder: os.PathLike = "", output_format: str = "csv"):
def save_output(self, output_folder: os.PathLike = "", output_format: str = "csv", indexing: bool = False):
"""
Save the objects of session data to user preferred location or a default folder
:param output_folder: user preferred output location; default tmp directory
:param output_format: needed only for tables CSV or XLSX
:param indexing: row & column index consideration in the output
:return: location of the output
"""
input_fname = self.input_filename.rsplit('.')[0]
Expand All @@ -187,7 +188,7 @@ def save_output(self, output_folder: os.PathLike = "", output_format: str = "csv
output_format = "csv"
warnings.warn("Invalid 'output_format' given. Defaulted to 'csv'")

table_outputs_path = ConvertTo(server_response=self.server_response, output_format=output_format).output
table_outputs_path = ConvertTo(server_response=self.server_response, output_format=output_format, indexing=indexing).output

if output_folder:
if not os.path.exists(output_folder):
Expand Down
2 changes: 1 addition & 1 deletion ExtractTable/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (2, 1, 1)
VERSION = (2, 1, 2)
PRERELEASE = None # "alpha", "beta" or "rc"
REVISION = None

Expand Down
2 changes: 1 addition & 1 deletion ExtractTable/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _converter(self, fmt: str, indexing: bool = False, table_obj="TableJson") ->
warnings.warn(f"There are {dfs} tables extracted. Consider to change the output_format to 'csv' instead")
with pd.ExcelWriter(output_excel_location) as writer:
for n, df in enumerate(dfs):
df.to_excel(writer, f'table_{n+1}')
df.to_excel(writer, f'table_{n+1}', index=indexing, header=indexing)
writer.save()
return [output_excel_location]
elif fmt == "json":
Expand Down

0 comments on commit c48fe70

Please sign in to comment.