when exporting csv the columns get doubled .nodejs mongo

Amadi Sajini 1 Reputation point
2021-07-15T17:12:32.147+00:00

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.

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,438 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AlexZhu-MSFT 5,626 Reputation points Microsoft Vendor
    2021-07-16T08:38:57.193+00:00

    Hi,

    Sorry for disappointing you, it seems the problem has nothing to do with Microsoft System Center Operations Manager (a monitoring tool, such as Nagios or Zabbix, not related to developing). Since Node.js and MongoDB are not Microsoft products, we may visit their corresponding forums to see it we can get help.

    https://nodejs.org/en/get-involved/

    https://www.mongodb.com/community/forums/

    Note: the above links are not from MS, just for your reference.

    Alex
    If the response is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments