title: Import data from .csv file to HTML Table using JavaScript
body: <p>I have saved excel file as .csv know I want to import that data into HTML table </p>
  
  <p>e.g. the data in the .csv file is as</p>
  
  <pre><code>Name, Father's Name, Roll No., Attendance
  abc,xyz,11011519-059,P
  abs,ijk,11011519-007,A
  </code></pre>
  
  <p>This code is working fine. It reads data successfully from .csv or .txt file but my problem is that I want that data in HTML Table. Can you please provide a simple solution which I can implement on this code.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Read File (via User Input selection)&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
          var reader; //GLOBAL File Reader object for demo purpose only
  
          /**
           * Check for the various File API support.
           */
          function checkFileAPI() {
              if (window.File &amp;&amp; window.FileReader &amp;&amp; window.FileList &amp;&amp; window.Blob) {
                  reader = new FileReader();
                  return true;
              } else {
                  alert('The File APIs are not fully supported by your browser. Fallback required.');
                  return false;
              }
          }
  
          /**
           * read text input
           */
          function readText(filePath) {
              var output = ""; //placeholder for text output
              if (filePath.files &amp;&amp; filePath.files[0]) {
                  reader.onload = function (e) {
                      output = e.target.result;
                      displayContents(output);
                  };//end onload()
                  reader.readAsText(filePath.files[0]);
              }//end if html5 filelist support
                          else { //this is where you could fallback to Java Applet, Flash or similar
                  return false;
              }
              return true;
          }
  
          /**
           * display content using a basic HTML replacement
           */
          function displayContents(txt) {
              var el = document.getElementById('main');
              el.innerHTML = txt; //display output in DOM
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>