Skip to content

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).

Terminal window
mpt part extract records/states.mpt states_psv

Pipe-friendly: the default output is body bytes only (no envelope).

Part-level header payload (toml/yaml/etc. inside the part):

Terminal window
mpt part extract records/states.mpt states_psv --header

Standalone single-part document (useful for templates):

Terminal window
mpt part extract records/states.mpt states_psv --full -o /tmp/states-only.mpt

Append from a body file and rewrite in place:

Terminal window
mpt part add records/states.mpt washington \
--body-file rows/wa.psv \
--header-file rows/wa-header.toml \
--in-place

Insert before an existing part:

Terminal window
mpt part add records/states.mpt intro --body-file intro.txt --before states_psv --in-place

Without --in-place or -o, the updated document is written to stdout (safe for scripts).

Terminal window
mpt part remove records/states.mpt washington --in-place

A document must keep at least one part.

Terminal window
mpt merge chapter-01.mpt chapter-02.mpt -o book.mpt

See merge file headers in the reference for header rules.

Terminal window
mpt validate records/states.mpt
mpt canonicalize records/states.mpt # optional: inspect normalized form