Skip to content

Add rename, flatten, and head/tail commands (0.4.0) - #5

Closed
rmkr-dev wants to merge 1 commit into
mainfrom
cursor/rename-flatten-head-tail-51dc
Closed

rmkr-dev wants to merge 1 commit into
mainfrom
cursor/rename-flatten-head-tail-51dc

Conversation

@rmkr-dev

@rmkr-dev rmkr-dev commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • rename renames top-level keys from OLD NEW pairs, on one object or each object in a list. Missing keys are left unchanged, non-objects are passed through, and renames apply in a single pass (a later pair wins if the same old key is repeated).
  • flatten collapses nested objects into top-level keys joined by --sep (default .). A list root is flattened item by item. Nested lists stay as values, empty objects stay empty, and a non-object root is returned unchanged.
  • head / tail return the first or last N items of a list root. N must be a non-negative integer. A count past the end returns the items that exist; 0 returns an empty list.

Helpers rename_keys, flatten_object, head_rows, and tail_rows live in shape.py and are exported from the package. Version is 0.4.0.

Test plan

  • pytest — 71 passed locally (shape unit tests and CLI smoke tests)
  • data-transform rename name title -f json on an object and on an array
  • data-transform flatten --sep _ -f json on a nested object
  • data-transform head 2 and data-transform tail 1 on a JSON array, including N=0 and a non-list root
Open in Web Open in Cursor 

Expose reusable shape helpers and matching CLI commands for renaming
top-level keys, flattening nested objects, and slicing list roots.

Co-authored-by: Ramkumar Ethiraj <rmkr-dev@users.noreply.github.com>
@rmkr-dev

Copy link
Copy Markdown
Owner Author

Superseded by #6.

@rmkr-dev rmkr-dev closed this Sep 28, 2026
@rmkr-dev
rmkr-dev deleted the cursor/rename-flatten-head-tail-51dc branch September 28, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants