'How to parse CSV file with string objectkeys instead of "raw" strings?

I tried parsing a CSV file in Javascript and I got the following results:

[ 
  {
    'Title': 'Random Brand 1',
    'Brand Code': '5205',
    Display: 'Brand'
  },
  {
    'Title': 'Random Brand 2',
    'Brand Code': '5201',
    Display: 'Sponsorship'
  },
  {
    'Title': 'Random Brand 3',
    'Brand Code': '5203',
    Display: 'Both'
  }
]

The "Title" keys are wrapped in quotes, but Display does not. "Brand Code" is in quotes which is fine because it's two words. How do I parse it so that Title will be like Display and has not quotes? Something like this:

  {
    Title: 'Random Brand 3',
    'Brand Code': '5203',
    Display: 'Both'
  }

I am parsing the file like this:

import csvParse from 'csv-parse/lib/sync'
const brands = csvParse(fs.readFileSync(csv), { columns: true })

Do I have to change something on Excel?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source