I need my code to be able to take data from a csv file and print it to the screen. At the moment it takes data from a txt file fine but a CSV will just return "file not supported". Here is my code.
<html>
<div id="page-wrapper">
<div>
Select a text file:
<input type="file" id="fileInput">
</div>
<pre id="fileDisplayArea"><pre>
</div>
<button onClick="test()">Show Text</button>
<script>
function test (){
var file = fileInput.files[0];
var textType = /text.*/;
if (file.type.match(textType)) {
var reader = new FileReader();
reader.onload = function(e) {
var look = reader.result;
window.alert (look);
}
reader.readAsText(file);
} else {
fileDisplayArea.innerText = "File not supported!";
}
}
</script>