CSV
Read CSV texts and files into JSON rows, with automatic detection of the encoding, the separator and the column types, and write JSON rows back to CSV.
csv sniff describes a file before you load it. Typical uses: import a supplier price list, export query results for a spreadsheet.csv parsecsv to_jsoncsv to_jsoncsv readcsv readcsv sniffcsv sniffcsv from_jsoncsv from_jsoncsv writecsv write
csv parse <namespace> <filePath> <columnSeparator> <quoteChar> <forceColumnNames> <mqlAction>
Description
Parse a CSV file
Parse a CSV file
Parameters
namespace: The namespace - string - required
filePath: The file path - string - required
columnSeparator: The column separator - string - required
quoteChar: The quote char - string - required
forceColumnNames: To force the column names (can be empty) - string - required
mqlAction: The MQL action to execute on each line - string - required
namespace: The namespace - string - required
filePath: The file path - string - required
columnSeparator: The column separator - string - required
quoteChar: The quote char - string - required
forceColumnNames: To force the column names (can be empty) - string - required
mqlAction: The MQL action to execute on each line - string - required
admin
csv parse (mql "T") (mql "/Users/jimmitry/Desktop/file.csv") (mql ",") (mql "'") (mql "A,B,C") { log trace [T_A]; };
mentdb
Used in use cases (7 recipes)
JSON & document store developer › Export a JSON array to a CSV file and read it back
SQL developer in MQL › CSV, XML and HTML for three partners
Excel reporting analyst › Bank CSV to a category summary with frozen values
Files & archives manager › Delivery package with a SHA-256 manifest, verified after unzip
API & database integrator › Transactional price import, then reports in every format
Integrator & ETL developer › Import a CSV from SFTP into a database, every morning
and 1 more in the Use cases
JSON & document store developer › Export a JSON array to a CSV file and read it back
SQL developer in MQL › CSV, XML and HTML for three partners
Excel reporting analyst › Bank CSV to a category summary with frozen values
Files & archives manager › Delivery package with a SHA-256 manifest, verified after unzip
API & database integrator › Transactional price import, then reports in every format
Integrator & ETL developer › Import a CSV from SFTP into a database, every morning
and 1 more in the Use cases
Often used with
mql · cm get · file create · json parse_array · sql connect · sql disconnect · file delete · sql dml
mql · cm get · file create · json parse_array · sql connect · sql disconnect · file delete · sql dml
csv to_json <text>
Description
Parse a CSV text into JSON rows: the separator, the decimal mark and the types of the columns are detected
Parse a CSV text into JSON rows: the separator, the decimal mark and the types of the columns are detected
Parameters
text: The CSV text - String - required
text: The CSV text - String - required
admin
csv to_json "nom;code;montant;date;actif \"Dupont; Jean\";00123;12,5;2026-01-02;true Martin;00456;7;2026-02-03;false"
mentdb
[{"nom": "Dupont; Jean", "code": "00123", "montant": 12.5, "date": "2026-01-02", "actif": true}, {"nom": "Martin", "code": "00456", "montant": 7, "date": "2026-02-03", "actif": false}]
admin
csv to_json "id,name,price 1,Widget,9.99 2,\"Gadget, large\",19.5 3,,4"
mentdb
[{"id": 1, "name": "Widget", "price": 9.99}, {"id": 2, "name": "Gadget, large", "price": 19.5}, {"id": 3, "name": null, "price": 4}]
csv to_json <text> <json_params>
Description
Parse a CSV text with parameters: separator (auto), quote ("), header (true; false gives c1, c2...), columns (forced names), skip (lines before the header), types (auto | string), decimal (auto | . | ,), null_values ([""]), trim (true), max_rows, extra (error | ignore: extra fields of a line)
Parse a CSV text with parameters: separator (auto), quote ("), header (true; false gives c1, c2...), columns (forced names), skip (lines before the header), types (auto | string), decimal (auto | . | ,), null_values ([""]), trim (true), max_rows, extra (error | ignore: extra fields of a line)
Parameters
text: The CSV text - String - required
json_params: The parameters - String - required
text: The CSV text - String - required
json_params: The parameters - String - required
admin
csv to_json "id,name,price 1,Widget,9.99 2,\"Gadget, large\",19.5 3,,4" "{\"types\": \"string\"}"
mentdb
[{"id": "1", "name": "Widget", "price": "9.99"}, {"id": "2", "name": "Gadget, large", "price": "19.5"}, {"id": "3", "name": null, "price": "4"}]
A title line to skip before the header
admin
csv to_json "Sales export 2026 shop;amount Paris;1250,5" "{\"skip\": 1}"
mentdb
[{"shop": "Paris", "amount": 1250.5}]
No header line, forced names, empty or NA values as null
admin
csv to_json "1|A|NA 2|B|7" "{\"header\": false, \"columns\": [\"id\", \"cat\", \"score\"], \"null_values\": [\"\", \"NA\"]}"
mentdb
[{"id": 1, "cat": "A", "score": null}, {"id": 2, "cat": "B", "score": 7}]
csv read <path>
Description
Read a CSV file into JSON rows (same detection as csv to_json: encoding with or without BOM, separator, decimal mark, types)
Read a CSV file into JSON rows (same detection as csv to_json: encoding with or without BOM, separator, decimal mark, types)
Parameters
path: The file path - String - required
path: The file path - String - required
admin
-> "[rows]" "[{\"shop\": \"Paris\", \"month\": \"2026-01\", \"amount\": 1250.5, \"code\": \"00042\"}, {\"shop\": \"Lyon\", \"month\": \"2026-01\", \"amount\": 980, \"code\": \"00043\"}, {\"shop\": \"Paris\", \"month\": \"2026-02\", \"amount\": 1310.25, \"code\": \"00042\"}]"; csv write "tmp/tuto_etl/sales.csv" [rows] "{\"separator\": \";\", \"decimal\": \",\", \"bom\": true}"; -> "[back]" (csv read "tmp/tuto_etl/sales.csv"); file delete "tmp/tuto_etl/sales.csv"; [back]
mentdb
[{"shop": "Paris", "month": "2026-01", "amount": 1250.5, "code": "00042"}, {"shop": "Lyon", "month": "2026-01", "amount": 980, "code": "00043"}, {"shop": "Paris", "month": "2026-02", "amount": 1310.25, "code": "00042"}]
csv read <path> <json_params>
Description
Read a CSV file with parameters: encoding (auto | UTF-8 | windows-1252 | ISO-8859-1...), separator, quote, header, columns, skip, types, decimal, null_values, trim, max_rows (the reading stops there: the first rows of a large file), extra
Read a CSV file with parameters: encoding (auto | UTF-8 | windows-1252 | ISO-8859-1...), separator, quote, header, columns, skip, types, decimal, null_values, trim, max_rows (the reading stops there: the first rows of a large file), extra
Parameters
path: The file path - String - required
json_params: The parameters - String - required
path: The file path - String - required
json_params: The parameters - String - required
admin
csv write "tmp/tuto_etl/codes.csv" "[{\"shop\": \"Paris\", \"month\": \"2026-01\", \"amount\": 1250.5, \"code\": \"00042\"}, {\"shop\": \"Lyon\", \"month\": \"2026-01\", \"amount\": 980, \"code\": \"00043\"}, {\"shop\": \"Paris\", \"month\": \"2026-02\", \"amount\": 1310.25, \"code\": \"00042\"}]" "{\"separator\": \";\"}"; -> "[res]" (csv read "tmp/tuto_etl/codes.csv" "{\"types\": \"string\", \"max_rows\": 2}"); file delete "tmp/tuto_etl/codes.csv"; [res]
mentdb
[{"shop": "Paris", "month": "2026-01", "amount": "1250.5", "code": "00042"}, {"shop": "Lyon", "month": "2026-01", "amount": "980", "code": "00043"}]
Used in use cases (2 recipes)
Integrator & ETL developer › Load a partner CSV file into a table: detection, typing, upsert and rejected rows
Integrator & ETL developer › Detect the encoding of a legacy export and convert it to UTF-8 before loading it
Integrator & ETL developer › Load a partner CSV file into a table: detection, typing, upsert and rejected rows
Integrator & ETL developer › Detect the encoding of a legacy export and convert it to UTF-8 before loading it
Often used with
csv write · file delete · file exist · csv sniff · file convert_encoding · file detect_encoding · file mkdir · sql bulk_upsert
csv write · file delete · file exist · csv sniff · file convert_encoding · file detect_encoding · file mkdir · sql bulk_upsert
csv sniff <path>
Description
Describe a CSV file before loading it: encoding, BOM, separator, quote, decimal mark, header, columns, type of each column, number of rows and the first 5 rows (all the rows are counted, the types come from the first 10 000 rows)
Describe a CSV file before loading it: encoding, BOM, separator, quote, decimal mark, header, columns, type of each column, number of rows and the first 5 rows (all the rows are counted, the types come from the first 10 000 rows)
Parameters
path: The file path - String - required
path: The file path - String - required
admin
csv write "tmp/tuto_etl/sniff.csv" "[{\"shop\": \"Paris\", \"month\": \"2026-01\", \"amount\": 1250.5, \"code\": \"00042\"}, {\"shop\": \"Lyon\", \"month\": \"2026-01\", \"amount\": 980, \"code\": \"00043\"}, {\"shop\": \"Paris\", \"month\": \"2026-02\", \"amount\": 1310.25, \"code\": \"00042\"}]" "{\"separator\": \";\", \"decimal\": \",\", \"bom\": true}"; -> "[res]" (csv sniff "tmp/tuto_etl/sniff.csv"); file delete "tmp/tuto_etl/sniff.csv"; [res]
mentdb
{"encoding": "UTF-8", "bom": true, "separator": ";", "quote": "\"", "decimal": ",", "header": true, "columns": ["shop", "month", "amount", "code"], "types": {"shop": "string", "month": "string", "amount": "number", "code": "string"}, "rows": 3, "sample": [{"shop": "Paris", "month": "2026-01", "amount": 1250.5, "code": "00042"}, {"shop": "Lyon", "month": "2026-01", "amount": 980, "code": "00043"}, {"shop": "Paris", "month": "2026-02", "amount": 1310.25, "code": "00042"}]}
csv sniff <path> <json_params>
Description
Describe a CSV file with parameters (the same as csv read: forced encoding, separator, skip...)
Describe a CSV file with parameters (the same as csv read: forced encoding, separator, skip...)
Parameters
path: The file path - String - required
json_params: The parameters - String - required
path: The file path - String - required
json_params: The parameters - String - required
admin
csv write "tmp/tuto_etl/legacy.txt" "[{\"shop\": \"Paris\", \"month\": \"2026-01\", \"amount\": 1250.5, \"code\": \"00042\"}, {\"shop\": \"Lyon\", \"month\": \"2026-01\", \"amount\": 980, \"code\": \"00043\"}, {\"shop\": \"Paris\", \"month\": \"2026-02\", \"amount\": 1310.25, \"code\": \"00042\"}]" "{\"separator\": \"|\", \"encoding\": \"windows-1252\"}"; -> "[res]" (csv sniff "tmp/tuto_etl/legacy.txt" "{\"encoding\": \"windows-1252\", \"separator\": \"|\"}"); file delete "tmp/tuto_etl/legacy.txt"; [res]
mentdb
{"encoding": "windows-1252", "bom": false, "separator": "|", "quote": "\"", "decimal": ".", "header": true, "columns": ["shop", "month", "amount", "code"], "types": {"shop": "string", "month": "string", "amount": "number", "code": "string"}, "rows": 3, "sample": [{"shop": "Paris", "month": "2026-01", "amount": 1250.5, "code": "00042"}, {"shop": "Lyon", "month": "2026-01", "amount": 980, "code": "00043"}, {"shop": "Paris", "month": "2026-02", "amount": 1310.25, "code": "00042"}]}
Used in use cases (1 recipe)
Integrator & ETL developer › Load a partner CSV file into a table: detection, typing, upsert and rejected rows
Integrator & ETL developer › Load a partner CSV file into a table: detection, typing, upsert and rejected rows
Often used with
csv read · csv write · file delete · file exist · file mkdir · sql bulk_upsert · sql connect · sql disconnect
csv read · csv write · file delete · file exist · file mkdir · sql bulk_upsert · sql connect · sql disconnect
csv from_json <json_rows>
Description
Format JSON rows as a CSV text (columns = the union of the keys in first-seen order; fields with the separator, a quote, a line break or edge spaces are quoted)
Format JSON rows as a CSV text (columns = the union of the keys in first-seen order; fields with the separator, a quote, a line break or edge spaces are quoted)
Parameters
json_rows: The rows - String - required
json_rows: The rows - String - required
admin
csv from_json "[{\"shop\": \"Paris\", \"month\": \"2026-01\", \"amount\": 1250.5, \"code\": \"00042\"}, {\"shop\": \"Lyon\", \"month\": \"2026-01\", \"amount\": 980, \"code\": \"00043\"}, {\"shop\": \"Paris\", \"month\": \"2026-02\", \"amount\": 1310.25, \"code\": \"00042\"}]"
mentdb
shop,month,amount,code Paris,2026-01,1250.5,00042 Lyon,2026-01,980,00043 Paris,2026-02,1310.25,00042
csv from_json <json_rows> <json_params>
Description
Format JSON rows as a CSV text with parameters: separator (,), quote ("), header (true), columns (order and subset), decimal (. | ,), line_end (\n | \r\n), quote_all (false), null (text of the null values)
Format JSON rows as a CSV text with parameters: separator (,), quote ("), header (true), columns (order and subset), decimal (. | ,), line_end (\n | \r\n), quote_all (false), null (text of the null values)
Parameters
json_rows: The rows - String - required
json_params: The parameters - String - required
json_rows: The rows - String - required
json_params: The parameters - String - required
admin
csv from_json "[{\"shop\": \"Paris\", \"month\": \"2026-01\", \"amount\": 1250.5, \"code\": \"00042\"}, {\"shop\": \"Lyon\", \"month\": \"2026-01\", \"amount\": 980, \"code\": \"00043\"}, {\"shop\": \"Paris\", \"month\": \"2026-02\", \"amount\": 1310.25, \"code\": \"00042\"}]" "{\"separator\": \";\", \"decimal\": \",\", \"columns\": [\"month\", \"shop\", \"amount\"]}"
mentdb
month;shop;amount 2026-01;Paris;1250,5 2026-01;Lyon;980 2026-02;Paris;1310,25
Nested values are written as JSON
admin
csv from_json "[{\"id\": 1, \"tags\": [\"a\", \"b\"], \"note\": null}]" "{\"null\": \"NULL\"}"
mentdb
id,tags,note 1,"[""a"", ""b""]",NULL
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
csv write <path> <json_rows>
Description
Write JSON rows into a CSV file (UTF-8, the directories are created); returns the file, the number of rows and the columns
Write JSON rows into a CSV file (UTF-8, the directories are created); returns the file, the number of rows and the columns
Parameters
path: The file path - String - required
json_rows: The rows - String - required
path: The file path - String - required
json_rows: The rows - String - required
admin
-> "[res]" (csv write "tmp/tuto_etl/out.csv" "[{\"shop\": \"Paris\", \"month\": \"2026-01\", \"amount\": 1250.5, \"code\": \"00042\"}, {\"shop\": \"Lyon\", \"month\": \"2026-01\", \"amount\": 980, \"code\": \"00043\"}, {\"shop\": \"Paris\", \"month\": \"2026-02\", \"amount\": 1310.25, \"code\": \"00042\"}]"); file delete "tmp/tuto_etl/out.csv"; [res]
mentdb
{"file": "tmp/tuto_etl/out.csv", "rows": 3, "columns": ["shop", "month", "amount", "code"]}
csv write <path> <json_rows> <json_params>
Description
Write JSON rows into a CSV file with parameters: the parameters of csv from_json, plus encoding (UTF-8) and bom (false; true helps Excel to open UTF-8 files)
Write JSON rows into a CSV file with parameters: the parameters of csv from_json, plus encoding (UTF-8) and bom (false; true helps Excel to open UTF-8 files)
Parameters
path: The file path - String - required
json_rows: The rows - String - required
json_params: The parameters - String - required
path: The file path - String - required
json_rows: The rows - String - required
json_params: The parameters - String - required
admin
csv write "tmp/tuto_etl/excel.csv" "[{\"shop\": \"Paris\", \"month\": \"2026-01\", \"amount\": 1250.5, \"code\": \"00042\"}, {\"shop\": \"Lyon\", \"month\": \"2026-01\", \"amount\": 980, \"code\": \"00043\"}, {\"shop\": \"Paris\", \"month\": \"2026-02\", \"amount\": 1310.25, \"code\": \"00042\"}]" "{\"separator\": \";\", \"decimal\": \",\", \"bom\": true, \"line_end\": \"crlf\"}"; -> "[res]" (csv sniff "tmp/tuto_etl/excel.csv"); file delete "tmp/tuto_etl/excel.csv"; [res]
mentdb
{"encoding": "UTF-8", "bom": true, "separator": ";", "quote": "\"", "decimal": ",", "header": true, "columns": ["shop", "month", "amount", "code"], "types": {"shop": "string", "month": "string", "amount": "number", "code": "string"}, "rows": 3, "sample": [{"shop": "Paris", "month": "2026-01", "amount": 1250.5, "code": "00042"}, {"shop": "Lyon", "month": "2026-01", "amount": 980, "code": "00043"}, {"shop": "Paris", "month": "2026-02", "amount": 1310.25, "code": "00042"}]}
Used in use cases (5 recipes)
Files & archives manager › Archive a month of logs into a .tar.xz or a .7z and prove that it can be restored
File transfer & remote systems engineer › Exchange files with a bank in PGP: encrypt and sign, decrypt and verify, check the fingerprint
Integrator & ETL developer › Load a partner CSV file into a table: detection, typing, upsert and rejected rows
System administrator & DevOps › Keep the daily export of a configuration in a Git repository and see what changed
Integrator & ETL developer › Detect the encoding of a legacy export and convert it to UTF-8 before loading it
Files & archives manager › Archive a month of logs into a .tar.xz or a .7z and prove that it can be restored
File transfer & remote systems engineer › Exchange files with a bank in PGP: encrypt and sign, decrypt and verify, check the fingerprint
Integrator & ETL developer › Load a partner CSV file into a table: detection, typing, upsert and rejected rows
System administrator & DevOps › Keep the daily export of a configuration in a Git repository and see what changed
Integrator & ETL developer › Detect the encoding of a legacy export and convert it to UTF-8 before loading it
Often used with
file delete · file exist · file mkdir · csv read · and · compress 7z · compress tarXz · compress un7z
file delete · file exist · file mkdir · csv read · and · compress 7z · compress tarXz · compress un7z
