cancel
Showing results for 
Search instead for 
Did you mean: 

How to create new array if there are more than 100 elements in the array

Igor_Bozhinovsk
New Contributor III

Hi , currently we have an array that contains more then 100 elements , approximately 168. Is it possible with some transformation in the mapper to create another array that will contain the rest 68 elements ?

We would have 1 array with 100 elements and the other should contain the rest of the elments.

Or we can split the array if there are more then 100 documents , that would work too.

1 ACCEPTED SOLUTION

Hi Sir,

See attached PoC pipeline. Hope this helps

image

canvas_2023_01_10.slp (11.7 KB)

Thanks,
EmEm

View solution in original post

8 REPLIES 8

marjan_karafilo
Contributor

Hi @Igor_Bozhinovski ,

You can take a look at Group By N snap, I think it will help you with this issue.

You can set Group Size to 100 and you will have two groups as output.

BR,
Marjan

Thanks Marjan , the array is part of the object and the Group By N snap doesnt seems to help.
The array looks like this:

SerialNumbers":[
{
“SerialNo”:“123”,
“SerialNo”:“456”,
}
]

Regards,
Igor

Hi Igor,

Then maybe Group by fields snap is the one you are looking for?

You can choose by which object to group by.

Let me know if this helps you.

BR,
Marjan

koryknick
Employee
Employee

@Igor_Bozhinovski - I think @marjan.karafiloski has a great idea here. Use the JSON Splitter to first break the array into individual documents, then use the Group By N snap to regroup them into the size you want. This will handle the case when your array grows beyond 200 so there are no groups that will be larger than 100.