Repository navigation
Add group-by, count, and unflatten commands (0.5.0) - #7
Merged
Merged
Conversation
Add group_rows, count_rows, and unflatten_object shape helpers and matching CLI commands. group-by buckets a list of objects by a top-level key, count reports totals, per-key counts, or group sizes from group-by output, and unflatten reverses flatten with the same --sep option. Document the new commands in the README and bump the version to 0.5.0.
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.
Three new shaping commands:
group-by KEYgroups a list of objects by a top-level key into{value: [items]}, keeping first-seen order. Non-string values are labelled as compact JSON, and items without the key are dropped.count [KEY]prints the length of a list. WithKEYit prints per-value counts, and when run ongroup-byoutput it prints the size of each group.unflatten [--sep]is the inverse offlatten. It rebuilds nested objects from joined keys and round-tripsflattenoutput.Each command has a pure helper in
shape.py(group_rows,count_rows,unflatten_object) with unit tests, plus CLI tests. The README is updated and the version is bumped to 0.5.0.Tests: 71 → 85, all passing locally.