From 5b6537aede83e73a92dfe14ba455ab4881b482f8 Mon Sep 17 00:00:00 2001 From: Bee Webb Date: Wed, 12 Jun 2024 12:18:12 +0000 Subject: [PATCH 1/3] fix: _get_column_letter -> get_column_letter in openpyxl https://github.com/OpenDataServices/flatten-tool/issues/443 There's no need for a conditional import as get_column_letter has existed since at laest openpyxl 2.6.0, which is the earliest version we support. --- CHANGELOG.md | 6 ++++++ flattentool/input.py | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff4e0cf..8665d88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Rename `_get_column_letter` import to `get_colunmn_letter` for compatibility + with latest openpyxl + https://github.com/OpenDataServices/flatten-tool/issues/443 + ## [0.24.1] - 2024-02-09 ### Fixed diff --git a/flattentool/input.py b/flattentool/input.py index 80d007d..8aacdce 100644 --- a/flattentool/input.py +++ b/flattentool/input.py @@ -24,7 +24,7 @@ except ImportError: SHAPELY_AND_GEOJSON_LIBRARIES_AVAILABLE = False -from openpyxl.utils.cell import _get_column_letter +from openpyxl.utils.cell import get_column_letter from flattentool.exceptions import DataErrorWarning from flattentool.i18n import _ @@ -386,11 +386,11 @@ def do_unflatten(self): actual_heading, ", ".join( [ - _get_column_letter(x + 1) + get_column_letter(x + 1) for x in ignoring[:-1] ] ), - _get_column_letter(ignoring[-1] + 1), + get_column_letter(ignoring[-1] + 1), sheet_name, ), DataErrorWarning, @@ -404,8 +404,8 @@ def do_unflatten(self): ) ).format( actual_heading, - _get_column_letter(ignoring[0] + 1), - _get_column_letter(ignoring[1] + 1), + get_column_letter(ignoring[0] + 1), + get_column_letter(ignoring[1] + 1), sheet_name, ), DataErrorWarning, @@ -419,7 +419,7 @@ def do_unflatten(self): ) ).format( actual_heading, - _get_column_letter(ignoring[0] + 1), + get_column_letter(ignoring[0] + 1), sheet_name, ), DataErrorWarning, @@ -445,7 +445,7 @@ def do_unflatten(self): else: cells[header] = Cell( line[header], - (sheet_name, _get_column_letter(k + 1), j + 2, heading), + (sheet_name, get_column_letter(k + 1), j + 2, heading), ) unflattened = unflatten_main_with_parser( self.parser, @@ -740,7 +740,7 @@ def get_sheet_headings(self, sheet_name): if self.vertical_orientation: return [ cell.value - for cell in worksheet[_get_column_letter(skip_rows + 1)][ + for cell in worksheet[get_column_letter(skip_rows + 1)][ configuration_line: ] ] @@ -777,7 +777,7 @@ def get_sheet_lines(self, sheet_name): worksheet = self.workbook[self.sheet_names_map[sheet_name]] if self.vertical_orientation: - header_row = worksheet[_get_column_letter(skip_rows + 1)] + header_row = worksheet[get_column_letter(skip_rows + 1)] remaining_rows = worksheet.iter_cols(min_col=skip_rows + header_rows + 1) if configuration_line: header_row = header_row[1:] From 2d5ec75d018896b533a5247e129159e9dac3d4ff Mon Sep 17 00:00:00 2001 From: Bee Webb Date: Wed, 12 Jun 2024 12:19:48 +0000 Subject: [PATCH 2/3] release: 0.24.2 --- CHANGELOG.md | 2 ++ setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8665d88..3b0ab3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.24.2] - 2024-06-12 + ### Fixed - Rename `_get_column_letter` import to `get_colunmn_letter` for compatibility diff --git a/setup.py b/setup.py index f65e663..518fb51 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def run(self): setup( name="flattentool", - version="0.24.1", + version="0.24.2", author="Open Data Services", author_email="code@opendataservices.coop", packages=["flattentool"], From 0d50f230224aa97303cf340a6d7694d431527711 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:12:08 -0400 Subject: [PATCH 3/3] fix: Apply null character filter on configuration sheet --- CHANGELOG.md | 7 +++++++ flattentool/input.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b0ab3b..86f002f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.24.3] + +### Fixed + +- Ignore null characters in the input CSV file when reading configuration from the header rows + https://github.com/OpenDataServices/flatten-tool/pull/446 + ## [0.24.2] - 2024-06-12 ### Fixed diff --git a/flattentool/input.py b/flattentool/input.py index 8aacdce..524b4c2 100644 --- a/flattentool/input.py +++ b/flattentool/input.py @@ -677,7 +677,7 @@ def get_sheet_configuration(self, sheet_name): with open( os.path.join(self.input_name, sheet_name + ".csv"), encoding=self.encoding ) as main_sheet_file: - r = csvreader(main_sheet_file) + r = csvreader(NullCharacterFilter(main_sheet_file)) heading_row = next(r) if len(heading_row) > 0 and heading_row[0] == "#": return heading_row[1:]