Edit parts in an mpt file
Goal: change the contents of an .mpt file without hand-editing envelope lines.
Prerequisites: mpt CLI reference, a valid .mpt file, and the mpt binary (cargo build -p mpt from the vyutils repo).
Extract a part body
Section titled “Extract a part body”mpt part extract records/states.mpt states_psvPipe-friendly: the default output is body bytes only (no envelope).
Extract with metadata
Section titled “Extract with metadata”Part-level header payload (toml/yaml/etc. inside the part):
mpt part extract records/states.mpt states_psv --headerStandalone single-part document (useful for templates):
mpt part extract records/states.mpt states_psv --full -o /tmp/states-only.mptAdd a part
Section titled “Add a part”Append from a body file and rewrite in place:
mpt part add records/states.mpt washington \ --body-file rows/wa.psv \ --header-file rows/wa-header.toml \ --in-placeInsert before an existing part:
mpt part add records/states.mpt intro --body-file intro.txt --before states_psv --in-placeWithout --in-place or -o, the updated document is written to stdout (safe for scripts).
Remove a part
Section titled “Remove a part”mpt part remove records/states.mpt washington --in-placeA document must keep at least one part.
Merge two files
Section titled “Merge two files”mpt merge chapter-01.mpt chapter-02.mpt -o book.mptSee merge file headers in the reference for header rules.
Validate after edits
Section titled “Validate after edits”mpt validate records/states.mptmpt canonicalize records/states.mpt # optional: inspect normalized form