Fixed width files
fixed parse <text> <json_layout>
Description
Read fixed width text into rows
Read fixed width text into rows
Parameters
text: The text - String - required
json_layout: The layout - String - required
text: The text - String - required
json_layout: The layout - String - required
admin
fixed parse "41100001Dupont SA 000125050-20261031 41100002Martin 000008990020261102 " "[{\"name\": \"account\", \"length\": 8}, {\"name\": \"label\", \"length\": 12}, {\"name\": \"amount\", \"length\": 10, \"type\": \"decimal\", \"decimals\": 2, \"sign\": \"trailing\"}, {\"name\": \"date\", \"length\": 8, \"type\": \"date\"}]"
mentdb
[{"account": "41100001", "label": "Dupont SA", "amount": -1250.5, "date": "2026-10-31"}, {"account": "41100002", "label": "Martin", "amount": 899, "date": "2026-11-02"}]
fixed parse <text> <json_layout> <json_params>
Description
Read fixed width text with parameters (skip, skip_trailer, record_length, strict, on_error, encoding)
Read fixed width text with parameters (skip, skip_trailer, record_length, strict, on_error, encoding)
Parameters
text: The text - String - required
json_layout: The layout - String - required
json_params: The parameters - String - required
text: The text - String - required
json_layout: The layout - String - required
json_params: The parameters - String - required
admin
fixed parse "HEADER 20261103 01F0000104ACME 02CABLE 0020001050 02SWITCH0010004900 TRAILER 3 " "{\"record_type\": {\"start\": 1, \"length\": 2}, \"layouts\": {\"01\": [{\"name\": \"invoice\", \"start\": 3, \"length\": 8}, {\"name\": \"customer\", \"length\": 10}], \"02\": [{\"name\": \"item\", \"start\": 3, \"length\": 6}, {\"name\": \"qty\", \"length\": 3, \"type\": \"int\"}, {\"name\": \"price\", \"length\": 7, \"type\": \"decimal\", \"decimals\": 2}]}}" "{\"skip\": 1, \"skip_trailer\": 1}"
mentdb
[{"_type": "01", "invoice": "F0000104", "customer": "ACME"}, {"_type": "02", "item": "CABLE", "qty": 2, "price": 10.5}, {"_type": "02", "item": "SWITCH", "qty": 1, "price": 49}]
Records without line breaks
admin
fixed parse "AB12CD34EF56" "[{\"name\": \"code\", \"length\": 2}, {\"name\": \"n\", \"length\": 2, \"type\": \"int\"}]" "{\"record_length\": 4}"
mentdb
[{"code": "AB", "n": 12}, {"code": "CD", "n": 34}, {"code": "EF", "n": 56}]
Used in use cases (1 recipe)
Integrator & ETL developer › Read a mainframe fixed width export with header, trailer and two record types
Integrator & ETL developer › Read a mainframe fixed width export with header, trailer and two record types
fixed read <path> <json_layout>
Description
Read a fixed width file into rows
Read a fixed width file into rows
Parameters
path: The file path - String - required
json_layout: The layout - String - required
path: The file path - String - required
json_layout: The layout - String - required
admin
if (equal (file exist "tmp/tuto_etl") "0") {file mkdir "tmp/tuto_etl";}; file create "tmp/tuto_etl/in.txt" "A0001 012 A0002 007 "; -> "[res]" (fixed read "tmp/tuto_etl/in.txt" "[{\"name\": \"code\", \"length\": 5}, {\"name\": \"qty\", \"length\": 4, \"type\": \"int\"}]"); file delete "tmp/tuto_etl/in.txt"; [res]
mentdb
[{"code": "A0001", "qty": 12}, {"code": "A0002", "qty": 7}]
fixed read <path> <json_layout> <json_params>
Description
Read a fixed width file with parameters
Read a fixed width file with parameters
Parameters
path: The file path - String - required
json_layout: The layout - String - required
json_params: The parameters - String - required
path: The file path - String - required
json_layout: The layout - String - required
json_params: The parameters - String - required
admin
-> "[layout]" "[{\"name\": \"code\", \"length\": 5}, {\"name\": \"qty\", \"length\": 4, \"type\": \"int\"}]"; if (equal (file exist "tmp/tuto_etl") "0") {file mkdir "tmp/tuto_etl";}; file create "tmp/tuto_etl/stock.txt" "STOCK 2026-11-03 A0001 012 A0002 0x7 A0003 105 END "; -> "[res]" (fixed read "tmp/tuto_etl/stock.txt" [layout] "{\"skip\": 1, \"skip_trailer\": 1, \"on_error\": \"skip\"}"); file delete "tmp/tuto_etl/stock.txt"; [res]
mentdb
{"rows": [{"code": "A0001", "qty": 12}, {"code": "A0003", "qty": 105}], "rejected": ["line 3: field 'qty': '0x7' is not a number"]}
fixed format <json_rows> <json_layout>
Description
Write rows as fixed width text: numbers right-aligned and zero padded, texts left-aligned; a value too long is an error
Write rows as fixed width text: numbers right-aligned and zero padded, texts left-aligned; a value too long is an error
Parameters
json_rows: The rows - String - required
json_layout: The layout - String - required
json_rows: The rows - String - required
json_layout: The layout - String - required
admin
fixed format "[{\"account\": \"41100001\", \"label\": \"Dupont SA\", \"amount\": -1250.5, \"date\": \"2026-10-31\"}, {\"account\": \"41100002\", \"label\": \"Martin\", \"amount\": 899, \"date\": \"2026-11-02\"}]" "[{\"name\": \"account\", \"length\": 8}, {\"name\": \"label\", \"length\": 12}, {\"name\": \"amount\", \"length\": 10, \"type\": \"decimal\", \"decimals\": 2, \"sign\": \"trailing\"}, {\"name\": \"date\", \"length\": 8, \"type\": \"date\"}]"
mentdb
41100001Dupont SA 000125050-20261031 41100002Martin 000008990020261102
fixed format <json_rows> <json_layout> <json_params>
Description
Write fixed width text with parameters: truncate (cut the values too long), replace_newlines (a line break in a value becomes a space, refused otherwise), line_end (lf, crlf or none), encoding (checks that every character can be written)
Write fixed width text with parameters: truncate (cut the values too long), replace_newlines (a line break in a value becomes a space, refused otherwise), line_end (lf, crlf or none), encoding (checks that every character can be written)
Parameters
json_rows: The rows - String - required
json_layout: The layout - String - required
json_params: The parameters - String - required
json_rows: The rows - String - required
json_layout: The layout - String - required
json_params: The parameters - String - required
admin
fixed format "[{\"code\": \"A1\", \"label\": \"A very long product label\"}]" "[{\"name\": \"code\", \"length\": 4}, {\"name\": \"label\", \"length\": 10}]" "{\"truncate\": true, \"line_end\": \"crlf\"}"
mentdb
A1 A very lon
fixed write <path> <json_rows> <json_layout>
Description
Write rows to a fixed width file (the directories are created)
Write rows to a fixed width file (the directories are created)
Parameters
path: The file path - String - required
json_rows: The rows - String - required
json_layout: The layout - String - required
path: The file path - String - required
json_rows: The rows - String - required
json_layout: The layout - String - required
admin
-> "[layout]" "[{\"name\": \"code\", \"length\": 5}, {\"name\": \"qty\", \"length\": 4, \"type\": \"int\"}]"; fixed write "tmp/tuto_etl/out.txt" "[{\"code\": \"A0001\", \"qty\": 12}, {\"code\": \"A0002\", \"qty\": 7}]" [layout]; -> "[res]" (file load "tmp/tuto_etl/out.txt"); file delete "tmp/tuto_etl/out.txt"; [res]
mentdb
A00010012 A00020007
fixed write <path> <json_rows> <json_layout> <json_params>
Description
Write a fixed width file with parameters
Write a fixed width file with parameters
Parameters
path: The file path - String - required
json_rows: The rows - String - required
json_layout: The layout - String - required
json_params: The parameters - String - required
path: The file path - String - required
json_rows: The rows - String - required
json_layout: The layout - String - required
json_params: The parameters - String - required
admin
-> "[layout]" "[{\"name\": \"account\", \"length\": 8}, {\"name\": \"label\", \"length\": 12}, {\"name\": \"amount\", \"length\": 10, \"type\": \"decimal\", \"decimals\": 2, \"sign\": \"trailing\"}, {\"name\": \"date\", \"length\": 8, \"type\": \"date\"}]"; -> "[rows]" "[{\"account\": \"41100001\", \"label\": \"Dupont SA\", \"amount\": -1250.5, \"date\": \"2026-10-31\"}, {\"account\": \"41100002\", \"label\": \"Martin\", \"amount\": 899, \"date\": \"2026-11-02\"}]"; fixed write "tmp/tuto_etl/bank.txt" [rows] [layout] "{\"encoding\": \"windows-1252\", \"line_end\": \"crlf\"}"; -> "[back]" (fixed read "tmp/tuto_etl/bank.txt" [layout] "{\"encoding\": \"windows-1252\"}"); file delete "tmp/tuto_etl/bank.txt"; [back]
mentdb
[{"account": "41100001", "label": "Dupont SA", "amount": -1250.5, "date": "2026-10-31"}, {"account": "41100002", "label": "Martin", "amount": 899, "date": "2026-11-02"}]
