Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c48fe70

Browse files
User Control on Indices in the output (#34)
* User control over indices in the output with `indexing` * v2.1.2 * User control over indices in the output with `indexing`
1 parent b9622f6 commit c48fe70

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

‎ExtractTable/__init__.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,12 @@ def process_file(
173173
result = ConvertTo(server_response=trigger_resp, output_format=output_format, indexing=indexing).output
174174
return result
175175

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

190-
table_outputs_path = ConvertTo(server_response=self.server_response, output_format=output_format).output
191+
table_outputs_path = ConvertTo(server_response=self.server_response, output_format=output_format, indexing=indexing).output
191192

192193
if output_folder:
193194
if not os.path.exists(output_folder):

‎ExtractTable/__version__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (2, 1, 1)
1+
VERSION = (2, 1, 2)
22
PRERELEASE = None # "alpha", "beta" or "rc"
33
REVISION = None
44

‎ExtractTable/common.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _converter(self, fmt: str, indexing: bool = False, table_obj="TableJson") ->
6060
warnings.warn(f"There are {dfs} tables extracted. Consider to change the output_format to 'csv' instead")
6161
with pd.ExcelWriter(output_excel_location) as writer:
6262
for n, df in enumerate(dfs):
63-
df.to_excel(writer, f'table_{n+1}')
63+
df.to_excel(writer, f'table_{n+1}', index=indexing, header=indexing)
6464
writer.save()
6565
return [output_excel_location]
6666
elif fmt == "json":

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /