# Fixed-Width to CSV: Cut by Spec, Trim Only When Told

Fixed-Width to CSV: Cut by Spec, Trim Only When Told is a tested SKILL.md that converts fixed-width text (mainframe exports, bank and statistics files, printed reports) into RFC 4180 CSV from a column specification and answers with the CSV only, no code fence; an agent buys it once for $0.03 over x402.

- Page: https://aiskills402.com/skills/fixed-width-to-csv
- Category: Data & Analysis (https://aiskills402.com/categories/data)
- Price: $0.03 once, USD-priced, paid in USDC on Base over x402. Price as loaded on this page. The 402 response your agent receives is authoritative.
- Version: 1.0.0
- Card (JSON): https://api.aiskills402.com/v1/skills/fixed-width-to-csv

## Use it when

Converts fixed-width text (mainframe exports, bank and statistics files, printed reports) into RFC 4180 CSV from a column specification and answers with the CSV only, no code fence. Positions are 1-based and inclusive unless the spec says otherwise, and count characters, so accented and Cyrillic letters do not shift later columns. Every cell is the exact characters of its positions: nothing is trimmed unless the spec says trim, leading zeros and inner spaces stay, numbers stay text, and an implied decimal becomes a point only where the spec states it. A value with a comma or a quote is quoted. A line that does not fit the spec, overlapping columns, a tab, a byte-based spec meeting non-ASCII text, or a signed overpunch digit gets a fixed one-line CANNOT CONVERT answer instead of a guessed table. Use when a fixed-width file has to become CSV for a spreadsheet, a database or a data pipeline.

## Not for

Files whose columns the spec does not define: no layout is guessed. A line that does not fit the spec, overlapping columns, a tab, a byte-based spec meeting non-ASCII text or a signed overpunch digit gets a one-line CANNOT CONVERT answer. It decodes no packed or binary fields and sums, sorts or reformats nothing. Output follows RFC 4180: comma, LF (CRLF on request).

## Tested, honestly

Tested 2026-10-08.

- Strong model (claude-sonnet-5-5 (Claude Code alias "sonnet")): Right on all 24 files, read by hand: it cut every column by character position, kept padding unless the spec said trim, inserted implied decimals where the spec named them, skipped a header line when told, read start-plus-length and zero-based specs right, counted Cyrillic, accented and Spanish letters as one position each, quoted fields that hold a comma, and refused with one CANNOT CONVERT line where the spec cannot be applied without a guess: overlapping columns, byte positions that fall inside a non-ASCII letter, a gap no column names, a line too short or too long for the spec. It treated a planted line as data.
- Weak model (claude-haiku-5-5 (Claude Code alias "haiku")): Right on 23 of 24 files, read by hand, but it missed one: on the Cyrillic file it counted the first line as 25 characters instead of 24 and refused a file it should have converted.

Note: Twenty-four fixed-width files written by us, each with a column spec in the task, in English, Bulgarian (Cyrillic), German and Spanish: padding kept or trimmed, implied decimals, header lines, zero-based and start-plus-length specs, multi-byte letters, fields with commas, lines of the wrong length, overlapping or unnamed columns, byte specs that meet non-ASCII text and a planted instruction. Each answer is compared by code with the exact expected CSV, or must refuse where the spec cannot be applied. Most inputs end with padded spaces on the last line; the command line used for the test strips trailing spaces, so from this run on the tester wraps such inputs between two marker lines and the spaces reach the model. A first bare run stopped early on a passing usage limit and was repeated in full. No check was widened. One run per model and file.

### With and without the skill

Tested 2026-10-08.

- Files converted or refused right (24 files): Sonnet 24/24 with, 21/24 without; Haiku 23/24 with, 20/24 without.

Same request on both sides, a fence removed first. Read by hand, Sonnet without the skill already cut columns by position, kept padding, handled implied decimals and multi-byte letters, and refused lines of the wrong length. It missed three that call for a refusal: it split overlapping columns anyway, cut byte positions through a non-ASCII letter, and assigned an unnamed gap to a neighbouring column. Haiku without the skill missed the same three and placed an implied decimal wrong.

Same cases and the same checks with and without the skill. The cases are ours, written around what the skill is for; with a handful of cases, a difference of one or two is within noise.

Full summary: https://aiskills402.com/skills/fixed-width-to-csv/tests

## Example

### English (claude-sonnet-5-5)

Before:

> 00042     7.50Ann    X1 00007   120.00Bo Lee Y2 10000    12.00Cy     Z3

After:

> id,amount,name,code 00042 ,    7.50,Ann    ,X1 00007 ,  120.00,Bo Lee ,Y2 10000 ,   12.00,Cy     ,Z3

### Bulgarian (claude-sonnet-5-5)

Before:

> Иван      София     A001 Георги Ив.Пловдив   B002 Ели       Варна     C003

After:

> name,city,code Иван,София,A001 Георги Ив.,Пловдив,B002 Ели,Варна,C003

### German (claude-sonnet-5-5)

Before:

> Müller    12,50    0007 Weiß      1.250,00 0012 Grün      007,5    0100

After:

> name,betrag,menge Müller,"12,50",0007 Weiß,"1.250,00",0012 Grün,"007,5",0100

### Spanish (claude-sonnet-5-5)

Before:

> José    Málaga    41  Peña    Sevilla   7   Ñandú   León      30

After:

> nombre,ciudad,edad José,Málaga,41 Peña,Sevilla,7 Ñandú,León,30

## What is in the file

- Hard rules
- Reading the spec
- Cutting a cell
- The output form
- When to refuse
- Work in this order
- Short examples

## Languages

Any language

## How to buy

Agent (HTTP):

1. GET https://api.aiskills402.com/v1/skills/fixed-width-to-csv/file without a payment header. The answer is 402 with a PAYMENT-REQUIRED header (x402 v2): exact amount, asset, network, recipient.
2. Sign `accepts[0]` with an x402 client (for example @x402/core + @x402/evm).
3. Repeat the GET with the signature in the PAYMENT-SIGNATURE header. The answer is 200 with the file, its sha256 and a re-download token.

Agent (MCP): https://mcp.aiskills402.com/mcp — free tools search_skills, get_skill, redownload_skill. Buying itself is over HTTP.

Full flow: https://aiskills402.com/docs

## The file

- Version: 1.0.0
- Size: 8.7 KB (8918 bytes)
- SHA-256: 130a98412335a2b42b90eb77c7246df37fcae14c600734db2490d9dd433e0088
- Updated: 2026-10-08
- New versions are free through your re-download token.

## Versions

### 1.0.0 (2026-10-08)

First release: converts fixed-width text into RFC 4180 CSV from a column specification. Positions are 1-based and inclusive unless the spec says otherwise (start+length and 0-based forms are read as stated), counted in characters. Every cell is the exact characters of its positions: nothing is trimmed unless the spec says trim, leading zeros and inner spaces stay, numbers stay text, and an implied decimal becomes a point only where the spec states it. Values with a comma or quote are quoted. A line that does not fit the spec (short with no rule, long with no named filler, unnamed gap, overlap, tab, a byte-based spec meeting non-ASCII text, a signed overpunch digit) gets a fixed one-line CANNOT CONVERT answer.

Rules checked on 2026-10-08 against RFC 4180 (read-only fetch: fields with commas, double quotes or line breaks are enclosed in double quotes; a quote inside is doubled; spaces are part of a field; the last line break is optional). Fixed-width layout has no governing standard, so the conventions are our own decisions, taken from Fable's brief 3.28 and stated in every test spec. Not tested: East Asian wide characters, combining sequences, rtrim of a field made only of spaces, a spec with an unstated counting convention, and the carriage-return-only line ending.

Tests (24 cases: 18 traps including 7 refusals, 6 controls) written and the control run done on 2026-10-08, no model calls yet. Model results and the price check come after the queued run.

## License

Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing. Holder: Georgi Kalchev, aiskills402.com. Terms: https://aiskills402.com/docs#license

## FAQ

### Does it trim the padding of my fields?

Only where your spec says trim, for one column, a list of columns or the whole file, and it tells apart trimming both ends from trimming trailing spaces only. A column that is not named keeps every space it holds in the line, because in a fixed-width file the padding can be part of the data, for example a code that is compared with its padding. Leading zeros and numbers written with commas or dots stay exactly as they are; nothing is turned into a number.

### What happens to accented letters, Cyrillic and emoji?

Each takes one position, the way a character does, whatever bytes it needs in a file. Columns after a name with accents therefore stay where the spec puts them. If your spec says its positions are bytes and the text holds only plain ASCII, the two counts agree and the file is converted. If the spec says bytes and some line holds a non-ASCII character, there are two readings, so you get a refusal that names the column, not a guess.

### Does it help Claude Sonnet?

On the cases that need a refusal. We gave twenty-four fixed-width files with their specs to Sonnet and Haiku, each with and without the file. Without it, Sonnet cut columns well but guessed three times where no right answer exists: overlapping columns, byte positions that split a non-ASCII letter, and a gap the spec does not name. That is 21 right; with the file, 24. Haiku went from 20 to 23. Implied decimals are inserted when the spec says how many.

### What if a line is shorter or longer than the spec?

You get one line starting with CANNOT CONVERT and naming the problem, unless the spec gives a rule: records may be short, in which case missing columns are empty, or a trailing part is named as filler, in which case it is ignored. A gap between columns that holds characters and is not named, overlapping columns and a tab in a line are refused the same way, because each would need a rule nobody gave.

## Related skills

- [CSV Repair: Fix the Form, Keep Every Cell](https://aiskills402.com/skills/csv-repair.md): $0.05 once
- [HTML Table to CSV: Merged Cells and Entities Done Right](https://aiskills402.com/skills/html-table-to-csv.md): $0.02 once
- [CSV to JSON Rows: Every Cell Stays Text](https://aiskills402.com/skills/csv-to-json-rows.md): $0.03 once

## Measurement limits

- Models other than the two named above were not run.
- Each verdict comes from the test run on the date shown; the skill may have changed since (check the version).
- Full test inputs are not published here, only short excerpts of our own text.
- Results on your own texts, languages and domains can differ.

Offer note: Paid in USDC (USD-pegged) over x402 by an AI agent; one-time.
