Converting CSV data to Javascript arrays was already discussed here, but this is another case.
Assuming we have CSV-formated data structured like this:
one,two
three,four
five,six
We can use split() function or libraries like jquery-csv or Papa Parse to convert it into a JS array structured like:
[['one', 'two'], ['three', 'four'], ['five', 'six']]
But how to convert it into arrays containing data of first and second 'column' respectively? Like:
[['one', 'three', 'five'], ['two', 'four', 'six']]
We can, of course, iterate through obtained key-value pair arrays and push keys and values into separate arrays, but is there a way to get it structured like this directly from CSV?
Parsing CSV data into an array can be resource hungry enough, so it is good to skip unnecessary actions.