From b2e54cda9deb4d5e703c33da194ae7bcd99d52cd Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:34:09 -0400 Subject: [PATCH] fix(in2csv): Recalculate the dimensions of an XLSX file, instead of trusting the file's metadata, closes #1129 --- CHANGELOG.rst | 5 +++++ csvkit/utilities/in2csv.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e703d30e4..ec3b09f32 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +Unreleased +---------- + +fix: :doc:`/scripts/in2csv` `recalculates `_ the dimensions of XLSX files, instead of trusting the file's metadata. + 1.3.0 - October 18, 2023 ------------------------ diff --git a/csvkit/utilities/in2csv.py b/csvkit/utilities/in2csv.py index 03e9b5f05..4351fb292 100644 --- a/csvkit/utilities/in2csv.py +++ b/csvkit/utilities/in2csv.py @@ -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.') @@ -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()):