1

I want to make a bulk insert from a csv with columns names different to the ones in my database. I am developing a React web and would like to convert it to json with the correct columns names.

Here is an example

Csv:
Prod,price,stock
Shirt,200,12

Json:

{User_prod:'Shirt',User_price:'200',user_stock:'12'}

Thanks!

dimay
  • 2,768
  • 1
  • 13
  • 22
Raijo
  • 15
  • 4
  • this may help https://stackoverflow.com/questions/27979002/convert-csv-data-into-json-format-using-javascript – Kais Aug 05 '20 at 04:50

1 Answers1

1

You can use the react csv libraries for loading and manipulating the csv header.

  1. https://www.npmjs.com/package/react-csv-reader
  2. https://www.npmjs.com/package/react-csv
Paras Patidar
  • 21
  • 1
  • 1
  • 6