10-26-2023 09:49 AM
I have data that looks like this:
I want to achieve the following result:
Please help!
Solved! Go to Solution.
10-26-2023 11:06 PM - edited 10-26-2023 11:43 PM
Hi @vgautam64 , I am unable to attached pipeline. so give you an example-
Data:
10-27-2023 12:46 AM
Hey @vgautam64,
Try the following expression:
$group.reduce((acc,curr,ind)=> acc.extend(curr.mapKeys((val,key)=>key+ind)),{})
Regards,
Bojan
10-26-2023 09:52 AM
@bojanvelevski @dmiller @tstack can you help?
10-26-2023 09:58 AM
Note that this is just an example and the number of objects in the group array is not fixed.
10-26-2023 10:26 AM
Thanks for bumping this up. I haven't had a chance to take a look into it yet, but let me see what I can do or who I can find to help (unfortunately, @tstack is no longer around).
10-26-2023 06:42 PM
This is a pretty gross expression, but you could put this in a mapper to achieve the result, since the output is an object rather than array, the order likely doesn't really matter in this case:
$group.reduce((acc, val, ind) => acc.extend(...val.entries().map((k) => {[k[0] + (ind+1)]: k[1]})), {})