CSV dialect detect
csv-dialect-detect · version 1.0.0 · CSV & tables · free, no key needed
Detect delimiter, quote, escape, record separator, and header for one rectangular CSV sample.
Use when you need to: detect csv dialect · detect csv delimiter and quote character · identify csv record separator.
Decide before calling
Read the versioned contract and the supported scope below. Reuse csv-dialect-detect@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use csv-dialect-detect@1.0.0 for detect csv dialect. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- detect csv dialect
- detect csv delimiter and quote character
- identify csv record separator
- decide whether a csv header row is present
- classify csv escape and quoting
- choose a rectangular csv dialect from a sample
- זיהוי ניב של טבלה מופרדת
Not supported
- guess a dialect by character frequency
- detect a dialect from a ragged or one-column sample
- strip a byte order mark or trim cells while detecting
Behavior
- Candidates are a fixed list: comma, tab, semicolon, and pipe with quote " and doubled quotes; space with quote | only when the sample contains |; comma with backslash escapes only when the sample contains a backslash. Each is tried with LF, CRLF, and CR.
- A candidate fits only when parsing succeeds, the rows are rectangular, there are at least two fields, the delimiter occurs, and a record separator occurs. A single record with no separator fits only the LF candidate.
- Zero fits is not_computable insufficient_structure. Two or more fits is not_computable ambiguous_dialect, with details.candidates sorted. A limit hit with no fit is rethrown as limit_exceeded.
- Header: with one record, header is absent. Otherwise up to 20 data rows vote. A column is numeric or a single code-point length; a conflict drops the column. Numeric columns vote for a header when the first cell is not numeric. Length columns vote for a header when its length differs. Header is present only when the total is positive.
- Assumptions, sorted, record which choice was not evidenced: escape_default_double, quote_default_double_quote, record_separator_default_lf, header_default_absent_single_record.
- Cells are not returned. No Unicode normalization, no trim, and no comment stripping. The same sample always yields the same object.
Input
sample(string, required): min length 1; max length 1024
Output
dialect(object, required)assumptions(array of one of "escape_default_double", "header_default_absent_single_record", "quote_default_double_quote", "record_separator_default_lf", required): max items 4record_count(integer, required): min 1; max 64field_count(integer, required): min 2; max 8
Limits
- max input bytes: 1024
- max records: 64
- max fields: 8
- max field bytes: 256
- max output bytes: 4096
- max depth: 8
Example
Request input:
{
"sample": "name,age\nAda,36\nGrace,45\n"
}
Response:
{
"result": {
"dialect": {
"delimiter": ",",
"quote": "\"",
"escape": "double",
"record_separator": "\n",
"header": "present"
},
"assumptions": [
"escape_default_double",
"quote_default_double_quote"
],
"record_count": 3,
"field_count": 2
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "csv-dialect-detect",
"version": "1.0.0",
"input": {
"sample": "name,age\nAda,36\nGrace,45\n"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/csv-dialect-detect/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"sample":"name,age\nAda,36\nGrace,45\n"}'
The machine-readable contract is at /v1/tools/csv-dialect-detect/versions/1.0.0.
CLI
node cli.mjs run csv-dialect-detect 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- CSV dialect format: Format string rows as CSV for an explicit dialect, quoting a one-field empty record when it can.
- CSV dialect parse: Parse CSV with an explicit dialect into string rows, keeping leading zeros and embedded breaks.
- CSV split column: Split one CSV column on an exact separator into uniquely named columns.
- CSV add row number: Prepend a 1-based row_number column of canonical integer strings.
- CSV anti join: Keep left CSV rows whose exact key tuples do not appear in the right document.
- CSV merge columns: Join named CSV columns with an exact separator into one column.