I encountered an issue where I am reading data from a CSV file, storing the innerHTML to a variable (named content), which the browser recognizes as a string. However, when attempting to convert it to an array, I am facing difficulties. I attempted to use split() but it is not functioning correctly for me.
function readAsText() {
var file = document.getElementById("file").files[0];
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function (f) {
var result = document.getElementById("result");
result.innerHTML = this.result;
content = result.innerHTML
arr1 = content.split(" /n")
arr2 = content.split(" ")
}
}
Based on the image provided, split() seems to successfully split the string but results in a single item.