From 42872cca1f87344f9e19ba0bf217c8ff808e624d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Am=C3=A9lie=20Rondot?= Date: Mon, 29 Jan 2024 10:58:37 +0100 Subject: [PATCH] Refacto: Move added block dealing with missing required labels in __open_run_stream() TableResource method --- frictionless/resources/table.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/frictionless/resources/table.py b/frictionless/resources/table.py index fc9dfe3af3..9f886501a3 100644 --- a/frictionless/resources/table.py +++ b/frictionless/resources/table.py @@ -310,18 +310,6 @@ def row_stream(): for row_number, cells in enumerated_content_stream: self.stats.rows += 1 - # NB: missing required labels are not included in the - # field_info parameter used for row creation - if self.detector.schema_sync: - for field in self.schema.fields: - if ( - field.name not in self.labels - and field.name in field_info["names"] - ): - field_index = field_info["names"].index(field.name) - del field_info["names"][field_index] - del field_info["objects"][field_index] - del field_info["mapping"][field.name] row = Row( cells, field_info=field_info, @@ -398,7 +386,16 @@ def row_stream(): # Yield row yield row - # Create row stream + # NB: missing required labels are not included in the + # field_info parameter used for row creation + if self.detector.schema_sync: + for field in self.schema.fields: + if field.name not in self.labels and field.name in field_info["names"]: + field_index = field_info["names"].index(field.name) + del field_info["names"][field_index] + del field_info["objects"][field_index] + del field_info["mapping"][field.name] + # # Create row stream self.__row_stream = row_stream() # Read