title: validate CSV (RFC 4180) using JS, (preferably angular)
body: <p>[Question reformulated]</p>
  
  <p>I've got an input type=file that allows the user to choose a file from disk. The actual upload process is already working fine:</p>
  
  <p>upload.html:</p>
  
  <pre><code>&lt;input type="file" file-upload accept=".csv" /&gt;
  </code></pre>
  
  <p>directive:</p>
  
  <pre><code>directive('fileUpload', ['$rootScope',
      function ($rootScope) {
          return {
              scope: true,
              link: function (scope, el, attrs) {
                  el.bind('change', function (event) {
                      var file = event.target.files[0];
                      $rootScope.$broadcast('fileSelected', { file: file });
                  });
              }
          };
      }
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>$scope.uploadCSVData = {};
  $scope.uploadCSVData.name = '';
  
  $scope.submitUpload = function () {
  $http({
  
      url: $api.$options.url + '/upload/list',
      method: 'POST',
      withCredentials: true,
      headers: {'Content-Type': 'multipart/form-data'},
      transformRequest: function (data) {
          var formData = new FormData();
          formData.append('data', angular.toJson($scope.uploadCSVData));
          formData.append('file' , $scope.file);
          return formData;
      }
  </code></pre>
  
  <p>Now I want to add a method to do some simple validation on the contents of that CSV file. I have read multiple articles about parsing CSV strings and validating them, but they always assume I have the actual string. </p>
  
  <p>In my case, I have a file and - while I can get lots of metadata about the file (such as last edited date, and even filesize) - I do not seem to have access to the data itself within JS so that I can validate it. </p>
  
  <pre><code>$scope.$on('fileSelected', function (event, args) {
      $scope.file = args.file;
      console.log($scope.file);
  });
  </code></pre>
  
  <p>The object looks like this:</p>
  
  <pre><code>File {
      lastModified: 1421877884000
      lastModifiedDate: Wed Jan 21 2015 17:04:44 GMT-0500 (Eastern Standard Time)
      name: "csv.csv"
      size: 5
      type: "application/vnd.ms-excel"
      webkitRelativePath: ""
  }
  </code></pre>
  
  <p>It currently contains one 5-letter string (just to test), but I cannot access the string. </p>
  
  <p><strong>How can I get the contents of the file into an object that I can then validate with JS?</strong></p>
  
  <p>Initial tests suggest I can perform an $http GET prior to performing the $http POST - but $http GET wants a URL, which points at a location on the server. I do not have a location on the server, since the user is using an input field to get the file directly. <strong>So how do I point my $http GET at the file that is already stored as $scope.file?</strong></p>