Fixed width records slice
fixed-width-records-slice · version 1.0.0 · Structured formats · free, no key needed
Slice selected fixed-width fields with explicit offsets, Unicode units, padding checks, and bounded diagnostics.
Use when you need to: slice fixed width records · project selected positional fields · extract raw fixed record columns.
Decide before calling
Read the versioned contract and the supported scope below. Reuse fixed-width-records-slice@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use fixed-width-records-slice@1.0.0 for slice fixed width records. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- slice fixed width records
- project selected positional fields
- extract raw fixed record columns
- select named flat file spans
- concatenate chosen fixed fields
- cut utf8 records by declared offsets
Not supported
- format or write fixed-width records
- infer layouts or field widths
- parse delimiter-separated CSV
Behavior
- Offsets are zero-based and half-open; declared field extents must not overlap; code_point counts Unicode scalar values and utf8_byte counts encoded bytes.
- Declared line_endings is enforced; any accepts LF, CRLF, or CR and normalizes them to records.
- A field beyond a record reports record_too_short; UTF-8 byte boundaries inside a sequence report split_utf8_sequence.
- left alignment removes trailing padding and requires no non-padding after padding; right alignment is symmetric; none preserves bytes/code points.
- Input order determines record, field, and selected-field output order; ties retain declaration order.
- At most 4,096 diagnostics are returned; discovering a 4,097th diagnostic throws limit_exceeded.
- Pure bounded slicing without clock, locale, network, or randomness.
Input
text(string, required): max length 262144fields(array of object, required): min items 1; max items 64unit(one of "code_point", "utf8_byte", required)line_endings(one of "lf", "crlf", "any", required)field_names(array of string, required): min items 1; max items 64; each min length 1; each max length 64
Output
reference_version(constant "Python 3.13 str slicing; GNU Coreutils cut 9.7", required)lines_in(integer, required): min 0; max 4096records(array of string, required): max items 4096; each max length 262144errors(array of object, required): max items 4096
Limits
- max input bytes: 262144
- max fields: 64
- max rows: 4096
- max diagnostics: 4096
- max output bytes: 1048576
Example
Request input:
{
"text": "ABCD",
"fields": [
{
"name": "a",
"offset": 0,
"width": 2,
"alignment": "none",
"padding": " "
},
{
"name": "b",
"offset": 2,
"width": 2,
"alignment": "none",
"padding": " "
}
],
"unit": "code_point",
"line_endings": "lf",
"field_names": [
"b"
]
}
Response:
{
"result": {
"reference_version": "Python 3.13 str slicing; GNU Coreutils cut 9.7",
"lines_in": 1,
"records": [
"CD"
],
"errors": []
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "fixed-width-records-slice",
"version": "1.0.0",
"input": {
"text": "ABCD",
"fields": [
{
"name": "a",
"offset": 0,
"width": 2,
"alignment": "none",
"padding": " "
},
{
"name": "b",
"offset": 2,
"width": 2,
"alignment": "none",
"padding": " "
}
],
"unit": "code_point",
"line_endings": "lf",
"field_names": [
"b"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/fixed-width-records-slice/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"text":"ABCD","fields":[{"name":"a","offset":0,"width":2,"alignment":"none","padding":" "},{"name":"b","offset":2,"width":2,"alignment":"none","padding":" "}],"unit":"code_point","line_endings":"lf","field_names":["b"]}'
The machine-readable contract is at /v1/tools/fixed-width-records-slice/versions/1.0.0.
CLI
node cli.mjs run fixed-width-records-slice 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Fixed width records parse: Parse fixed-width records with explicit offsets, widths, alignment, padding, Unicode units, and bounded diagnostics.
- Fixed width records validate: Validate fixed-width records with explicit offsets, widths, alignment, padding, Unicode units, and bounded diagnostics.
- Asn1 der node extract: Extract one DER node by a numeric path, with header, content, and child paths.
- XML exc c14n subtree: Exclusive XML Canonicalization 1.0 of one selected element and its descendants.
- Xpath10 count: Count the nodes in an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union.
- Xpath10 select: Select an XPath 1.0 node-set from location paths, axes, predicates, namespaces and union, in document order.