Why splitting CSV on commas fails

In a CSV file, a comma inside a quoted field belongs to the value. A line break inside quotes can belong to it too.

Read the fields inside quotes

Count two product rows in the CSV below. The second row takes up two lines because its shipping note contains a line break.

CSV input
product,note
"pen, blue",Single item
"Desk ""mini""","Ships flat
Handle with care"

line.split(",") would cut pen, blue into two fields. Splitting at each line break would also cut the shipping note in two. A CSV parser follows the quoting rules in RFC 4180 to keep those values together.

Convert the full table to JSON

Paste the sample into the CSV-to-JSON converter and leave the header option on. The output has one object per product. The header names become its keys, and the line break appears as \n.

JSON output
[
  {"product": "pen, blue", "note": "Single item"},
  {"product": "Desk \"mini\"", "note": "Ships flat\nHandle with care"}
]

To get just the product names, open the column converter and select product. For an export that uses pipes, choose Custom separator and enter |. A pipe inside a quoted field stays in the value.