Skip to content

Commit b16c73d

Browse files
Coding-Dev-ToolsDevForge Engineer
andauthored
refactor: remove dead _prepend_row code in CSV conversion path (#17)
The convert() function consumed one row via reader.read_stream() to get CSV field names, then used _prepend_row to re-attach it — but the result was never used (the file is re-read from scratch for the actual conversion). Removed the unused _prepend_row() utility and the dead re-attachment line. The field-order detection itself is preserved. Co-authored-by: DevForge Engineer <engineer@devforge.dev>
1 parent 73cc149 commit b16c73d

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

src/datamorph/converters.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,11 @@ def convert(
438438
field_names = [s["name"] for s in schema]
439439
writer.set_field_order(field_names)
440440
elif output_format == "csv":
441-
# Get field order from first few rows for CSV header
441+
# Get field order from first row for CSV header
442442
sample = reader.read_stream(input_path)
443443
try:
444444
first_row = next(sample)
445445
writer.set_field_order(list(first_row.keys()))
446-
# We consumed the first row, so we need to chain it back
447-
sample = _prepend_row(sample, first_row)
448446
except StopIteration:
449447
pass
450448

@@ -494,12 +492,6 @@ def convert_batch(
494492
return results
495493

496494

497-
def _prepend_row(stream: RowStream, row: Row) -> RowStream:
498-
"""Prepend a row to a stream (for re-inserting a consumed first row)."""
499-
yield row
500-
yield from stream
501-
502-
503495
def _format_to_extension(fmt: str) -> str:
504496
ext_map = {
505497
"csv": ".csv",

0 commit comments

Comments
 (0)