From 901325d266c797d4213334e62b223efc40e7238d Mon Sep 17 00:00:00 2001 From: DevForge Engineer Date: Mon, 18 May 2026 07:51:35 -0400 Subject: [PATCH] refactor: remove dead _prepend_row code in CSV conversion path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/datamorph/converters.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/datamorph/converters.py b/src/datamorph/converters.py index 187afeb..1761b69 100644 --- a/src/datamorph/converters.py +++ b/src/datamorph/converters.py @@ -438,13 +438,11 @@ def convert( field_names = [s["name"] for s in schema] writer.set_field_order(field_names) elif output_format == "csv": - # Get field order from first few rows for CSV header + # Get field order from first row for CSV header sample = reader.read_stream(input_path) try: first_row = next(sample) writer.set_field_order(list(first_row.keys())) - # We consumed the first row, so we need to chain it back - sample = _prepend_row(sample, first_row) except StopIteration: pass @@ -494,12 +492,6 @@ def convert_batch( return results -def _prepend_row(stream: RowStream, row: Row) -> RowStream: - """Prepend a row to a stream (for re-inserting a consumed first row).""" - yield row - yield from stream - - def _format_to_extension(fmt: str) -> str: ext_map = { "csv": ".csv",