โ12-09-2022 04:22 AM
Below is the Input
[
{
โ@idโ: โ2โ,
โcolโ: [
{
โ@idโ: โ2โ,
โ@transableโ: โyesโ,
โ$โ: โReplace1โ
},
{
โ@idโ: โ3โ,
โ@transableโ: โnoโ,
โ$โ: โReplace2โ
}
],
โgroupโ: [
{
โAโ: โA1โ,
โBโ: โB1โ,
โCโ: โC1โ,
โDโ: โD1โ,
โEโ: "E1 ",
โFโ: โF1โ,
โGโ: โG1โ,
โHโ: โโ,
โIโ: โโ
},
{
โAโ: โA2โ,
โBโ: โB2โ,
โCโ: โC2โ,
โDโ: โD2โ,
โEโ: โโ,
โFโ: โF2โ,
โGโ: โG2โ,
โHโ: โโ,
โIโ: โโ
}
]
}
]
expected Output :
[
{
"group": [
{
"A": "A1",
"B": "B1",
"C": "C1",
"D": "D1",
"E": "E1 ",
"F": "F1",
"G": "G1",
"H": "",
"I": ""
},
{
"A": "A2",
"B": "Replace1",
"C": "Replace2",
"D": "D2",
"E": "",
"F": "F2",
"G": "G2",
"H": "",
"I": ""
}
]
}
]
explanantion : @id refers to row number of the group and @id under col refers to the column number of the group where replacement needs to be done with the value of "$"
โ12-12-2022 05:26 PM
Hi @bojanvelevski , @alchemiz if i try hardcoding the record 1 , record2 in the expression i am getting as expected but how can we dynamically loop across all record?
โ12-12-2022 05:29 PM
Youโre trying to update the value from $row right?
$row.map(r=> r.mapValues((val,key)=> key == โcolโ ? val.map(c=> c.mapValues((v,k)=> k == โ$โ ? $group[r[โ@idโ] - 1].values()[c[โ@idโ] - 1] : v)) : val))
โ12-12-2022 05:37 PM
Hi @alchemiz its not my requirement actually i had listed my requirement above i am updating value obtained from row array to group array
โ12-12-2022 05:54 PM
$group.map((g,i)=> $row.find((a,b,c)=> a[โ@idโ] == i + 1) instanceof Object ? g.mapValues((val,key)=> $row.find((a,b,c)=> a[โ@idโ] == i + 1)[โcolโ].find((x,y,z)=> x[โ@idโ] == (key.charCodeAt(0) - 64)) instanceof Object ? $row.find((a,b,c)=> a[โ@idโ] == i + 1)[โcolโ].find((x,y,z)=> x[โ@idโ] == (key.charCodeAt(0) - 64))[โ$โ] : val ) : g )
โ12-12-2022 06:06 PM
hi @alchemiz thanks for helping but thats not exact requirement actually there are two arrays in input called row and group
and each looks like this as shown below
so according to position values (rowid & colid) need to update values of second array (group array)only
expected output: