Skip to content

Commit

Permalink
Refacto: Move added block dealing with missing required labels in __o…
Browse files Browse the repository at this point in the history
…pen_run_stream() TableResource method
  • Loading branch information
amelie-rondot committed Jan 29, 2024
1 parent 4ba3e64 commit 42872cc
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions frictionless/resources/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 42872cc

Please sign in to comment.