#1121·PapaParse

[Feature] Add automatic header detection

Author: cow1337killer3Created May 10, 2026Updated May 10, 2026

You can automatically detect headers like this:

For each cell, you can determine its “type”:

  • Empty
  • Boolean
  • Number
  • String: for strings, there’s 4 non-exclusive subtypes, and a cell can be more than 1 of them at the same time. Basically, each subtype is just if the cell contains certain kinds of characters, using the following patterns:
    • Digit: /\d/
    • Letter: /[a-zA-Z]/
    • Word: /(^|[ _\-\t])[a-zA-Z][a-zA-Z\-\‘]*([ _\-\t]|$)/
    • Punctuation: /[\?\!\.\,\:\;\’\”\/\-\(\)\&\[\]/
    • Special char: /\#\%\$\@\^\*\+\=\_\|\~\<\>\{\}\\/

Detecting a header:

  1. For the first row, find each column’s type(s)
  2. For all the other rows combined, find for each column:
    1. Possible types: add the type if it appears in any of the rows
    2. Universal types: add the type if it appears in every row
  3. Calculate a “difference score” for the first row:
    1. Each column of the first row is considered “different” if either:
      1. It has a type that doesn’t appear in the “possible types” of the other rows. Example: first row column contains a punctuation character but none of the other rows do
      2. It doesn’t have a type that appears in the “universal types” of the other rows. Example: every other row contains an @ symbol but the first row column doesn’t
    2. If a certain threshold of columns in the first row are different, it’s determined to be a header. Maybe that’d be by a certain % of columns, like >25% columns being different. Maybe you’d scale that based on the total # of rows, since there’s more certainty that the first row is different if there’s more rows to compare it to. Maybe scale the threshold from like 50% at <20 rows to 10% at >1000 rows