title: JSON to CSV with separated columns
body: <p>In an angular project im trying to implement a function to generate a CSV file from an array of objects.</p>
  
  <p>The array of objects populates a ng-Table so at first i tried to use: <a href="http://bazalt-cms.com/ng-table/example/15" rel="nofollow noreferrer">http://bazalt-cms.com/ng-table/example/15</a> 
  This worked great in chrome, in IE it doesnt work at all though because it needs to use the download attribute...</p>
  
  <p>Then i tried this approach</p>
  
  <pre><code>     var objArray = [
           { name: "Item 1", color: "Green", size: "X-Large" },
           { name: "Item 2", color: "Green", size: "X-Large" },
           { name: "Item 3", color: "Green", size: "X-Large" }];
  
      var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray;
      var str = '';
  
      for (var i = 0; i &lt; array.length; i++) {
          var line = '';
          for (var index in array[i]) {
              if (line != '') line += ','
  
              line += array[i][index];
          }
  
          str += line + '\r\n';
      }
  </code></pre>
  
  <p>But, now all the data of a row is in one single column. I want need the data on seperate columns. </p>
  
  <p>Expected output (once opened in Excel)</p>
  
  <p><img src="https://i.stack.imgur.com/3gOog.png" alt="enter image description here"></p>
  
  <p>Anyone got an idea how to do this?</p>