i try to export csv with users and their subcats.date,email,category type and subcats are the columns. but when i export the csv subcats get duplicated.not other date email category and type. only subcats get repeated. there are various subcats for a user. subcats are given to the user randomly but exactly there should be 15 subcats for a user among all subcats. following is my code.
var count = 0 var csv = []
users.forEach(userele => {
count++
let userObj = userele.users.map((val, index) => {
let object = {}
object[`${val.subCats}`] = getuser(val.user)
return object
})
for (key in userObj) {
userObj[" " + (parseInt(key) + 5)] = userObj[key]
delete userObj[key]
}
var expAr = {
"Date": Date,
"Email": userele.email,
"Category": userele.category,
"type": userele.type,
...userObj,
}
csv.push(expAr)
})
when i trying to export csv, the columns get repeated.i would appreciate if any one can give me a support to solve this.