I am having an issue getting rows from JSON and storing it in a separate {} object. This is how I structure my data.

[![enter image description here](https://i.stack.imgur.com/UJsiw.jpg)](https://i.stack.imgur.com/UJsiw.jpg)

After trying different techniques, I finally think this is close but not what I am looking for.

```
for(let i = 0; i < cols.length; i++){
   Object.values(allData.analysis[key]).slice(1).map(val => {
     console.log({[cols[i]]: val[i]})
   })
}

```

**allData** contains all the data including the header

```
name,age,gender
John Deo,45,male
Mary Jeo,54,female
Saly Meo,55,female

```

**cols** contains only the header

---

After running the above code this is what I got.

**What I have so far.**

[![enter image description here](https://i.stack.imgur.com/pSiM7.jpg)](https://i.stack.imgur.com/pSiM7.jpg)

**What I am looking for to accomplish.**

[![enter image description here](https://i.stack.imgur.com/eV5lr.jpg)](https://i.stack.imgur.com/eV5lr.jpg)

I am happy to provide more sample codes!