I have following array of arrays (2D Array)
Input csvData = [["", "2", "", ""], ["", "3", "", ""], ["", "", "4", ""]]
How to remove empty columns from above array.
Output csvData = [[ "2", ""], ["3", ""], ["","4"]]
I am trying but not able to complete.
removeEmptyColumns(csvData) {
for (let i = 0; i < csvData.length; i++) {
let col = csvData.map(function (value, index) { return value[i]; });
for (let j = 0; j < col.length; j++) {
if (col[j])
break;
}
}
}
csvData = [[ "2", ""], ["3", ""], ["", "4"]]?