My supplier's CSV has no header row. How do I convert it to JSON without losing the first data row?
Untick 'First row holds column names'. The tool then treats every line as data and produces an array of arrays, where each inner array is one row with its values in order. It still compares every row's length with the first and warns you about any row with more or fewer fields.
What happens if you forget the option
A supplier sends a price list with just two lines, a product code then a price, and no headers:
A1,10
B2,20
With the default setting the tool assumes the first line is a header. A1 and 10 become key names, and out comes a single object saying A1 is B2 and 10 is 20. Product A1 has vanished from the data and turned into a column name, and the summary reports 1 row instead of 2. That is the first warning sign: if the row count is one fewer than you expect and the key names look like data, the file has no header.
The correct output with the option off
With 'First row holds column names' unticked, the output became:
[ ["A1", "10"], ["B2", "20"] ]
Two rows in two columns, nothing lost. Each row is an array whose first value is the product code and second the price, and the values are strings because number conversion is off by default.
Steps
- Open the CSV and JSON converter and choose 'CSV to JSON'.
- Paste the file's contents or open it.
- Untick 'First row holds column names'.
- Check the summary: the row count should equal the number of data lines.
- Copy or download the JSON.
Uneven rows in a headerless file
Without a header, the tool cannot know how many columns there should be, so it takes the first row's length as the reference. We tried three lines: A1,10 then B2,20,x then C3 on its own. All three rows came out as they were, with two notes: row 2 has 3 fields where 2 were expected, and row 3 has 1 where 2 were expected. Numbering here starts at the first data line, because there is no header row to count.
These notes do not stop the conversion, but they tell you where to look before handing the JSON to any system.
Should I add the headers myself instead?
If whoever uses the JSON needs objects with names like sku and price, it is simpler to add a header line at the top of the file before pasting, such as sku,price, and leave the option ticked. You then get one named object per product. If the developer expects arrays, or the file is large and you would rather not edit it, unticking the option is enough.
To sort the list before converting, say by product code, you can order the lines in the Line sorter and paste them here.
Common questions
Does the same option matter for JSON to CSV?
Yes. Unticked there, the file is written without a header row.
Do the values change when the option is off?
No. The values are the same; they simply come out as arrays instead of named objects.
How can I tell a file has no header?
Look at the first line: if it resembles the rest of the data, numbers and codes rather than column names, there is no header.
