I am trying to remove the empty array elements (from a csv file) by using the splice()
function.
The array elements are stored inside csv.data
:
csv.data.forEach(function(item,index) {
if (item.length < 2) { // don't want anything less than two
csv.data.splice(index,1);
}
});
This works, but it still returns me two empty arrays (lines) in the csv file, originally, there are six empty lines, but it skips the two empty lines.
Am I doing anything wrong?
This is the csv.data
[
[
"1212",
"okay",
""
],
[
""
],
[
""
],
[
""
],
[
""
],
[
""
],
[
""
]
]
Expected
[
[
"1212",
"okay",
""
],
]