chore(csv2rry): initial commit
This commit is contained in:
parent
dd24d78a86
commit
398781fae0
|
@ -0,0 +1,12 @@
|
||||||
|
function csvToArr(stringVal, splitter) {
|
||||||
|
const [keys, ...rest] = stringVal
|
||||||
|
.trim()
|
||||||
|
.split("\n")
|
||||||
|
.map((item) => item.split(splitter));
|
||||||
|
const formedArr = rest.map((item) => {
|
||||||
|
const object = {};
|
||||||
|
keys.forEach((key, index) => (object[key] = item.at(index)));
|
||||||
|
return object;
|
||||||
|
});
|
||||||
|
return formedArr;
|
||||||
|
}
|
Loading…
Reference in New Issue