Repository navigation
fix: align appended emissions records to existing CSV headers - #1443
Conversation
davidberenstein1957
left a comment
There was a problem hiding this comment.
Good fix for #1442: reindexing the appended row to the file's header is safe because has_valid_headers already guarantees the same column set, and the test uses a real CSV. One ordering note for the maintainers: #1419 touches the same file for a problem master has already fixed, so it should be closed before this one merges, otherwise it would conflict.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1443 +/- ##
=======================================
Coverage 92.07% 92.07%
=======================================
Files 49 49
Lines 5199 5202 +3
=======================================
+ Hits 4787 4790 +3
Misses 412 412 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Reuse the header row read for has_valid_headers when reordering the appended record, and document that reindex() relies on that check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, The test is good: it compares every field of the appended row through I've done small changes: The CSV header is now read once and used both for the check and for reordering the appended row:
|
Fixes #1442.
Align append records with the existing CSV's header order before writing a headerless row.
has_valid_headersalready allows reordered headers, but the append path previously wrote values in dataclass order, corrupting their column associations.Only the existing header is read, not historical rows. New-file and update-mode behavior is unchanged; all-None columns remain present.
Verification on Python 3.12.13:
The regression verifies every field in the appended row with
csv.DictReader, including identifiers, emissions, energy, and coordinates. Concurrent CSV writers, remote filesystems, visualization and API/dashboard integration were not tested.AI disclosure: autonomously reproduced, implemented, and tested using Perplexity Computer (GPT-6.1). No human review is claimed.
Combined with #1439 and #1441: 695 passed, two skipped, three integration cases deselected and twelve subtests passed. PR is open and ready for review; hosted verification workflows require maintainer approval. A successful PR-size labeler is not a hosted test pass.