Header Row Detection Heuristic
Flag a possible header when its labels are unique and nonempty and at least half of columns have text labels above consistently numeric values; this is an explicit heuristic.
Description
Header inference is uncertain because text data can resemble labels.
Header inference is uncertain because text data can resemble labels. A transparent heuristic makes its limited evidence visible.1
Flag a possible header when its labels are unique and nonempty and at least half of columns have text labels above consistently numeric values; this is an explicit heuristic.
When to use Header Row Detection Heuristic
Use this for the following task: Flag a possible header when its labels are unique and nonempty and at least half of columns have text labels above consistently numeric values; this is an explicit heuristic.
Prepare the CSV text, decoded cells or byte values requested below. Choose delimiter and header flags explicitly when those fields are present.
How to use Header Row Detection Heuristic and understand its results
- Prepare the CSV text, decoded cells or byte values requested below. Choose delimiter and header flags explicitly when those fields are present.
- Enter csv, delimiter using the field table, then run the tool.
- Read likelyHeader, evidenceColumns, columnCount. Interpret flags, units, ordering and placeholder values using the rules below.
- Review any reported issue or failed check, correct the supplied values when appropriate, and verify the result in its intended context.
| Input field | Meaning | Value type and bounds | Requirement |
|---|---|---|---|
| csv | CSV text | string; maximum text length 100000 | Required |
| delimiter | Delimiter | string; choose ",", ";", "\t" | Required |
Parse rectangular records. Count columns where the first cell is not a supported decimal and all observed nonblank later cells are numeric. Require at least one observed later value per evidence column.2
Parse delimiters only outside quoted fields and decode doubled quotes. A quoted line break stays inside its cell; malformed quoting is returned as an input error.
likelyHeader = nonempty unique first-row labels AND evidenceColumns ≥ ceil(width/2) This summarizes the declared operation. Units, indexing, inclusivity and exceptional cases are explained in the surrounding text.
| Output field | Meaning | Value type |
|---|---|---|
| likelyHeader | Likely header | boolean |
| evidenceColumns | Evidence columns | integer |
| columnCount | Column count | integer |
{
"input": {
"csv": "name,age\nAda,36\nGrace,85",
"delimiter": ","
},
"output": {
"likelyHeader": true,
"evidenceColumns": 1,
"columnCount": 2
}
} Limitations and assumptions
This does not remove the first row or guarantee header presence. Non-numeric data tables may have real headers this rule misses. Decimal parsing trims outer whitespace, requires digits before the separator and limits a numeric token to 200 characters.
Where CSV is parsed, the shared parser accepts comma, semicolon or tab separators, doubled quotes and quoted line breaks, with CR/LF/CRLF record endings. Blank records remain records. CSV inputs are bounded to 100000 UTF-16 units and 10000 fields. Malformed requests produce input errors. A successfully evaluated request can still contain false flags, empty result lists or a result outside the supplied threshold; those outcomes have the meanings stated above.
Alternative or Complementary methods
Choose Mixed-Type Column Detector Samples for this operation: Report observed nonblank ASCII token classes per CSV data column and whether more than one occurs; integer and decimal spellings are distinct classes even when inference can promote both to decimal. For a complementary task, use CSV Row Counter for this operation: Count CSV records including blank records and quoted multiline fields, with an explicit header flag; physical lines are not records.
Further background: Format and language reference: Header Row Detection Heuristic.
References
-
Format and language reference: Header Row Detection Heuristic — RFC Editor
-
Header Row Detection Heuristic — tool.io
Similar or alternative tools
- Mixed-Type Column Detector Samples
Report observed nonblank ASCII token classes per CSV data column and whether more than one occurs; integer and decimal spellings are distinct classes even when inference can promote both to decimal.
- CSV Row Counter
Count CSV records including blank records and quoted multiline fields, with an explicit header flag; physical lines are not records.