title: Reading contents of csv file in node.js
body: <p>I am trying to implement a module in nodejs(<em>just started working in nodejs</em>) which has requirement below as</p>
  
  <ol>
  <li>Upload .csv file.</li>
  <li>Read content of the csv file.</li>
  </ol>
  
  <p>Frameworks currently being used for restful api is "express": "~4.2.0" and multer for file upload.</p>
  
  <p>Now I have configured multer like below in my <strong>app.js</strong></p>
  
  <pre><code>app.use(multer({
    onFileUploadData : function(file, data){
      console.log('onFileUploadData Called with data - '+ data);
    }
  }));
  </code></pre>
  
  <p>In my route file, I have a post endpoint like below</p>
  
  <pre><code>app.post('/sample.csv',lead.processCSV);
  </code></pre>
  
  <p>This route is being called from an ajax call below as</p>
  
  <pre><code>$.ajax({
              xhrFields: {withCredentials: true},
              url: '/sample.csv',
              type: 'POST',
              success: function (data) {
                  $scope.handleResponse(data);
              },
              error: function (error, xhr) {
                  angular.element('#csvUploadBusyIcon').hide();
                  alert('Oops! Upload failed');
              },
              data: formData,
              cache: false,
              contentType: false,
              processData: false
          });
  </code></pre>
  
  <p>Now I want to get the content of the csv file, i.e. when all the content has been loaded then I should handle my <strong>lead.processCSV</strong> method.</p>
  
  <p>Also do I need any other module for csv files, or multer is sufficient in my case?</p>
  
  <p>Any suggestion/guidance in right direction will be helpful. Thanks in Advance. </p>