fjordtools / Errors / CSV: duplicate column name

CSV: duplicate or empty column name

When the first row of a CSV becomes the keys of JSON objects, every column needs a name, and no name may appear twice. A repeated key leaves only one of the values when JSON is read, so the converter stops instead. Rename the columns, or choose the arrays output, which keeps all of them.

Fjordtools team · Seen in CSV files from spreadsheets, databases and exports · Published · 1 min read

Common causes

  1. The same name twice

    Two columns called id would become two keys called id in one object.

    Input

    id,id
    1,2

    CSV JSON says

    Column name "id" appears twice, in columns 1 and 2 of row 1. JSON objects need unique keys; rename one, or use the arrays output
  2. A trailing delimiter in the header

    A comma at the end of the first row adds a column with no name.

    Input

    id,name,
    1,Ann,

    CSV JSON says

    Column 3 has no name in row 1. JSON objects need a key for every column; name it, or use the arrays output
  3. An unnamed index column

    Some tools export a row number column with an empty header. It needs a name before it can be a key.

    Input

    ,name
    0,Ann

    CSV JSON says

    Column 1 has no name in row 1. JSON objects need a key for every column; name it, or use the arrays output
  4. The arrays output

    Arrays have no keys, so repeated and empty header names are not a problem. The header row stays as the first array.

    Input

    id,id
    1,2

    CSV JSON says

    [["id","id"],[1,2]]

How to fix it

  1. Rename the repeated column in the first row, for example id and id_2.
  2. Name the empty column, or delete it together with its values.
  3. Remove a trailing delimiter from every row, header included.
  4. Switch the converter to the Arrays output, or turn Header row off, if you need every column as it is.

Related errors

More error explainers are coming

See all errors.