Repository navigation
Include keys from every row when deriving CSV columns - #665
Open
shaurya703 wants to merge 1 commit into
Open
shaurya703 wants to merge 1 commit into
shaurya703 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
When
columnsis not passed,to_csvderives the columns from the first row only, so any key that first appears in a later row is silently dropped from the output.Before, this returns
'a\n1\n3\n', and thebcolumn and its value are lost.After, it returns
'a,b\n1,\n3,2\n'.CSVSerializer.encodenow builds the columns from the keys of every dict row. Columns stay sorted the same way, and a row missing a key still gets an empty cell, as it did before.Related issue
None. I found this while testing the serializers.
Checklist before requesting a review
test_encode_csv_rows_with_different_keysfails without the change and passes with it. In the full suite on Python 3.13 (989 passed), the only 2 failures aretest_read_content_from_s3andtest_write_content_to_s3, which fail the same way without this change becauseboto3cannot be imported in my local environment.