I have the following data string from a table and it looks like this:
The data format is correct, each row goes to a new line due to the amount of data.
const data =
"0 | john | doe |
US | Employed
1 | bob| dylan |
US | Unemployed "
How can I efficiently map data to the correct format? I want to output to an array of objects per row like below:
[{rowId: 0, name: "john", surname: "doe"}. {...}]
I initially tried to split by pipe it but it looked like this:
["0 ", " john ", " doe ", "US ", " Employed 1", " bob", " dylan ", "US ", " Unemployed"]
trimstrings