title: convert CSV lines into Javascript objects
body: <p>I have a simple csv file </p>
  
  <p>people.csv:</p>
  
  <pre><code>fname, lname, uid, phone, address
  John, Doe, 1, 444-555-6666, 34 dead rd
  Jane, Doe, 2, 555-444-7777, 24 dead rd
  Jimmy, James, 3, 111-222-3333, 60 alive way
  </code></pre>
  
  <p>What I want to do it get each line of the CSV, convert it to a JavaScript object, store them into an array, and then convert the array into a JSON object. </p>
  
  <p>server.js: </p>
  
  <pre><code>var http = require('http');
  var url  = require('url');
  var fs = require('fs');
  
  var args = process.argv;
  var type = args[2] || 'text';
  var arr = []; 
  var bufferString; 
  
  function csvHandler(req, res){
    fs.readFile('people.csv',function (err,data) {
  
    if (err) {
      return console.log(err);
    }
  
    //Convert and store csv information into a buffer. 
    bufferString = data.toString(); 
  
    //Store information for each individual person in an array index. Split it by every newline in the csv file. 
    arr = bufferString.split('\n'); 
    console.log(arr); 
  
    for (i = 0; i &lt; arr.length; i++) { 
      JSON.stringify(arr[i]); 
    }
  
    JSON.parse(arr); 
    res.send(arr);  
  });
  }
  
  //More code ommitted
  </code></pre>
  
  <p>My question is if I am actually converting that CSV lines into Javascript objects when I call the .split('\n') method on bufferString or is there another way of doing so?</p>