// Source: https://blog.mounirmesselmeni.de/2012/11/20/reading-csv-file-with-javascript-and-html5-file-api/ // Source: https://www.js-tutorials.com/javascript-tutorial/reading-csv-file-using-javascript-html5/ function handleFile(path) { // Check for the various File API support. if (window.FileReader) { // FileReader are supported. getAsText(file); } else { alert('FileReader are not supported in this browser.'); } } function getAsText(fileToRead) { var reader = new FileReader(); // Read file into memory as UTF-8 // TODO: fileToRead is the path to the file -> create a file handle reader.readAsText(fileToRead); // Handle errors load reader.onload = loadHandler; reader.onerror = errorHandler; } function loadHandler(event) { var csv = event.target.result; processData(csv); } function processData(csv) { var table = ""; var allTextLines = csv.split(/\r\n|\n/); for (var i = 0; i < allTextLines.length; i++) { var data = allTextLines[i].split(';'); table += ""; for (var j = 0; j < data.length; j++) { table += ""; } table += "
"; table += data[j]; table += ""; } table += "
"; document.getElementById('table_bla').innerHTML = table; } function errorHandler(evt) { if (evt.target.error.name == "NotReadableError") { alert("Canno't read file !"); } }