{"slug":"fixed-width-to-csv","name":"Fixed-Width to CSV: Cut by Spec, Trim Only When Told","version":"1.0.0","updated_at":"2026-10-08T20:05:03.689Z","use_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).","languages":["any"],"tags":["fixed-width","csv","rfc-4180","column-spec","mainframe","data-conversion","no-guessing"],"category":"data","category_url":"https://aiskills402.com/categories/data","keywords":["fixed-width file","column spec","implied decimal"],"faq":[{"q":"Does it trim the padding of my fields?","a":"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."},{"q":"What happens to accented letters, Cyrillic and emoji?","a":"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."},{"q":"Does it help Claude Sonnet?","a":"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."},{"q":"What if a line is shorter or longer than the spec?","a":"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."}],"examples":[{"lang":"en","model":"claude-sonnet-5-5","input_excerpt":"00042     7.50Ann    X1\n00007   120.00Bo Lee Y2\n10000    12.00Cy     Z3","output_excerpt":"id,amount,name,code\n00042 ,    7.50,Ann    ,X1\n00007 ,  120.00,Bo Lee ,Y2\n10000 ,   12.00,Cy     ,Z3"},{"lang":"bg","model":"claude-sonnet-5-5","input_excerpt":"Иван      София     A001\nГеорги Ив.Пловдив   B002\nЕли       Варна     C003","output_excerpt":"name,city,code\nИван,София,A001\nГеорги Ив.,Пловдив,B002\nЕли,Варна,C003"},{"lang":"de","model":"claude-sonnet-5-5","input_excerpt":"Müller    12,50    0007\nWeiß      1.250,00 0012\nGrün      007,5    0100","output_excerpt":"name,betrag,menge\nMüller,\"12,50\",0007\nWeiß,\"1.250,00\",0012\nGrün,\"007,5\",0100"},{"lang":"es","model":"claude-sonnet-5-5","input_excerpt":"José    Málaga    41 \nPeña    Sevilla   7  \nÑandú   León      30","output_excerpt":"nombre,ciudad,edad\nJosé,Málaga,41\nPeña,Sevilla,7\nÑandú,León,30"}],"page_url":"https://aiskills402.com/skills/fixed-width-to-csv","markdown_url":"https://aiskills402.com/skills/fixed-width-to-csv.md","image_url":"https://cdn.aiskills402.com/og/skills/fixed-width-to-csv/d54507fe.png","related_url":"https://api.aiskills402.com/v1/skills/fixed-width-to-csv/related","purchases_count":null,"tested":{"date":"2026-10-08","strong":{"model":"claude-sonnet-5-5 (Claude Code alias \"sonnet\")","verdict":"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\")","verdict":"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.","baseline":{"date":"2026-10-08","rows":[{"label":"Files converted or refused right (24 files)","better":"higher","strong":{"with":{"n":24,"of":24},"without":{"n":21,"of":24}},"weak":{"with":{"n":23,"of":24},"without":{"n":20,"of":24}}}],"note":"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."},"report_url":null},"price_usd":"0.03","price_micro":30000,"size_bytes":8918,"sha256":"130a98412335a2b42b90eb77c7246df37fcae14c600734db2490d9dd433e0088","outline":["Hard rules","Reading the spec","Cutting a cell","The output form","When to refuse","Work in this order","Short examples"],"license":{"summary":"Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing","holder":"Georgi Kalchev, aiskills402.com","url":"https://aiskills402.com/docs#license"},"buy_url":"https://api.aiskills402.com/v1/skills/fixed-width-to-csv/file","redownload_url_template":"https://api.aiskills402.com/v1/purchases/{token}","mcp_tool":null,"payment":{"protocol":"x402","scheme":"exact","asset":"USDC","selling":true,"network":"base","network_caip2":"eip155:8453","pay_to":"0x8e37022edcf0f21cf3c9f93fee9d4d32519f36f4","facilitator":"cdp"},"seo_title":"Fixed-Width to CSV Skill by Column Spec","seo_description":"Converts fixed-width text to RFC 4180 CSV by character position: padding kept unless trimmed, implied decimals, bad specs refused. Pay $0.03 once, in USDC.","versions":[{"version":"1.0.0","date":"2026-10-08","changelog":"# Changelog\n\n## 1.0.0 — 2026-10-08\n\nFirst 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.\n\nRules 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.\n\nTests (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.\n\n## 1.0.1 — 2026-10-08 (finalised after the model test)\n\n- Measured on 24 files: Sonnet 21 -> 24 of 24, Haiku 20 -> 23 (without -> with the skill). No check was widened.\n- Inputs ending in padded spaces now reach the model intact (the tester wraps them in marker lines).\n- Price: $0.03 (Sonnet gain 3).\n"}]}