title: Loading a CSV file into an HTML table using javascript
body: <p>I want to create a webpage that loads a selected CSV file (from hard drive) and displays its contents using table HTML. </p>
  
  <p>The project incorporates two components and so far, I've been researching the latter; generating a table out of a nested array in javascript. </p>
  
  <p>For some reason, the columns do not appear the way they should.</p>
  
  <p>My code</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;table id="1"&gt; &lt;/table&gt;
  
  &lt;button onclick="createTable()"&gt;Create&lt;/button&gt;
  
  &lt;script&gt;
  function createTable() {
      var array = [[1,2,3],[4,5,6],[7,8,9]];
   document.getElementById("1").innerHTML = ""; //Clear.
   
   for (i = 0; i &lt; array.length; i++) { 
   document.getElementById("1").innerHTML += "&lt;tr&gt;";
    for (k = 0; k &lt; array[0].length; k++) {
      document.getElementById("1").innerHTML += "&lt;td&gt;" + array[i][k] + "&lt;/td&gt;" ;
    }
    document.getElementById("1").innerHTML += "&lt;/tr&gt;";
     }
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>