Fixed-Width to CSV Offset-Spec Parser
Slice physical text lines at strictly increasing zero-based UTF-16 offsets beginning at zero, keeping padding and taking the last field to line end; emit comma CSV with bounded materialization.
Description
Fixed-width text stores fields at character offsets rather than delimiters.
Fixed-width text stores fields at character offsets rather than delimiters. Converting it requires a declared offset convention and line-boundary policy.1
Slice physical text lines at strictly increasing zero-based UTF-16 offsets beginning at zero, keeping padding and taking the last field to line end; emit comma CSV with bounded materialization.
When to use Fixed-Width to CSV Offset-Spec Parser
Use this for the following task: Slice physical text lines at strictly increasing zero-based UTF-16 offsets beginning at zero, keeping padding and taking the last field to line end; emit comma CSV with bounded materialization.
Prepare the CSV text, decoded cells or byte values requested below. Choose delimiter and header flags explicitly when those fields are present.
How to use Fixed-Width to CSV Offset-Spec Parser and understand its results
- Prepare the CSV text, decoded cells or byte values requested below. Choose delimiter and header flags explicitly when those fields are present.
- Enter text, offsets using the field table, then run the tool.
- Read csv. Interpret flags, units, ordering and placeholder values using the rules below.
- Review any reported issue or failed check, correct the supplied values when appropriate, and verify the result in its intended context.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| text | Text | string; maximum text length 100000 | Required |
| offsets | Offsets | list of integer; minimum entries 1; maximum entries 1000; each entry: integer; minimum 0; maximum 100000 | Required |
Require nonempty offsets beginning at zero and strictly increasing. Split physical CRLF/CR/LF lines, omit an extra terminal line, require each line reach the final offset, and write comma CSV while preserving padding.2
The shared writer doubles interior quotes and quotes cells when needed for delimiters or line breaks, including a single empty-field record. It normally emits LF record endings without a terminal newline; any tool-specific quote-all behavior is stated above.
field[i] = line.slice(offset[i],offset[i+1]); final field extends to line end This summarizes the declared operation. Units, indexing, inclusivity and exceptional cases are explained in the surrounding text.
| Output field | Meaning | Value type |
|---|---|---|
| csv | CSV text | string |
{
"input": {
"text": "001Ada 36\n002Grace85",
"offsets": [
0,
3,
8
]
},
"output": {
"csv": "001,Ada ,36\n002,Grace,85"
}
} Limitations and assumptions
Offsets count UTF-16 units rather than bytes or graphemes. At most 10000 output fields are materialized.
Supply the decoded cell strings or raw values declared by the input fields; this tool does not load a spreadsheet file. Malformed requests produce input errors. A successfully evaluated request can still contain false flags, empty result lists or a result outside the supplied threshold; those outcomes have the meanings stated above.
Alternative or Complementary methods
Choose Field Whitespace Trimmer for this operation: Trim ECMAScript boundary whitespace from every decoded CSV cell and re-encode with minimal quoting and LF record endings; interior whitespace is preserved. For a complementary task, use Column Select By Indices for this operation: Select and reorder zero-based columns from a rectangular CSV, allowing repeated selections while requiring at least one output column.
Further background: Format and language reference: Fixed-Width to CSV Offset-Spec Parser.
References
Similar or alternative tools
- Field Whitespace Trimmer
Trim ECMAScript boundary whitespace from every decoded CSV cell and re-encode with minimal quoting and LF record endings; interior whitespace is preserved.
- Column Select By Indices
Select and reorder zero-based columns from a rectangular CSV, allowing repeated selections while requiring at least one output column.