Skip to content

Commit

Permalink
fix(in2csv): Recalculate the dimensions of an XLSX file, instead of t…
Browse files Browse the repository at this point in the history
…rusting the file's metadata, closes #1129
  • Loading branch information
jpmckinney committed Oct 23, 2023
1 parent b4313a9 commit b2e54cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Unreleased
----------

fix: :doc:`/scripts/in2csv` `recalculates <https://openpyxl.readthedocs.io/en/stable/optimized.html#worksheet-dimensions>`_ the dimensions of XLSX files, instead of trusting the file's metadata.

1.3.0 - October 18, 2023
------------------------

Expand Down
4 changes: 2 additions & 2 deletions csvkit/utilities/in2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def main(self):
table = agate.Table.from_xls(self.input_file, sheet=self.args.sheet,
encoding_override=self.args.encoding_xls, **kwargs)
elif filetype == 'xlsx':
table = agate.Table.from_xlsx(self.input_file, sheet=self.args.sheet, **kwargs)
table = agate.Table.from_xlsx(self.input_file, sheet=self.args.sheet, reset_dimensions=True, **kwargs)
elif filetype == 'dbf':
if not hasattr(self.input_file, 'name'):
raise ValueError('DBF files can not be converted from stdin. You must pass a filename.')
Expand All @@ -177,7 +177,7 @@ def main(self):
tables = agate.Table.from_xls(self.input_file, sheet=sheets,
encoding_override=self.args.encoding_xls, **kwargs)
elif filetype == 'xlsx':
tables = agate.Table.from_xlsx(self.input_file, sheet=sheets, **kwargs)
tables = agate.Table.from_xlsx(self.input_file, sheet=sheets, reset_dimensions=True, **kwargs)

base = splitext(self.input_file.name)[0]
for i, (sheet_name, table) in enumerate(tables.items()):
Expand Down

0 comments on commit b2e54cd

Please sign in to comment.