title: Convert CSV file to JSON dictionary?
body: <p>I need to convert a large CSV data set to JSON, however the output should be a JSON dictionary like this:</p>
  
  <pre><code>var products = {
      "crystal": {
          "description": "This is a crystal",
          "price": "2.95"
      },
      "emerald": {
          "description": "This is a emerald",
          "price": "5.95"
      }
  };
  </code></pre>
  
  <p>This is what the CSV table would look like:
  <a href="https://i.stack.imgur.com/6H7qr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6H7qr.jpg" alt="enter image description here"></a></p>
  
  <p>I am using a script referenced <a href="https://stackoverflow.com/questions/18759516/convert-large-csv-files-to-json">here</a> to generate the JSON:</p>
  
  <pre><code>var csv = require('csv')
  var fs = require('fs')
  var f = fs.createReadStream('Fielding.csv')
  var w = fs.createWriteStream('out.txt')
  
  w.write('[');
  
  csv()
  .from.stream(f, {columns:true})
  .transform(function(row, index) {
      return (index === 0 ? '' : ',\n') + JSON.stringify(row);
  })
  .to.stream(w, {columns: true, end: false})
  .on('end', function() {
       w.write(']');
       w.end();
   });
  </code></pre>
  
  <p>However the output from that script is created in this format:</p>
  
  <pre><code>[
      {
          "name": "crystal",
          "description": "This is a crystal",
          "price": "2.95"
      },
      {
          "name": "emerald",
          "description": "This is a emerald",
          "price": "5.95"
      }
  ]
  </code></pre>
  
  <p>How would I modify the script to get my desired "dictionary" format?</p>