How to isolate one item of a bundle with the value of another item

Hi,

I’m trying to figure out how to use the numeric value of a string item (this is the output of a text parser module) to select an item from a bundle with the same value position within the bundle.

For example if the string item has a value of ‘2’ I’d like to forward the second item from a bundle to another module.

As far as I can see I need to know how to:
convert a string value to an integer,
use the numeric value of an item to select a sub item from a bundle.

Any help on this would be greatly appreciated.

Hey, Snape!

To convert a string to an integer you should use the parse number function, then you can build some logic by comparing numbers.

2 Likes

Hey thanks.

I’m new to make so it’s good to see how this is done.

It would be great to see how you would select an index of a collection using an integer variable.

It would be great to see screenshots of your scenario and data structures to be able to advise something :slight_smile:

2 Likes

Sure

This is the array I’ve built

and this is me attempting to select an item from the array using the variable

Having done some more research I’m trying this:


However this still results in a empty variable

Strangely if I hard code a fixed index such as 1, it returns the whole array whereas if I use 2 it returns nothing


As I can see your Array has a collection data type, so try to use the pick function instead of get.

pick (collection; key1; [key2; …])

But this function attempts keys instead of index.

Picks elements with the given keys from a collection. Returns a collection that contains only the picked elements. Useful when you want to pass a collection to an API, which expects an exact number of elements in the collection. Using this function, you can make sure your collection meets the requirements of the API.

Hi mania,

I tried this:

But it’s still coming up as an empty output

For more context this is the array setup:

Also might be worth mentioning that all I need returning is the string value of the array item, it doesn’t need to be in an particular container type like a collection

Now I’m wondering if the problem is the structure of the array/collection I’m trying to access:


Since it’s an array with 1 item and that item is a collection should I be doing something like this:

1 Like

Does it work as a result?

Nope, still returning empty :roll_eyes:

Hey@samliew,
your expertise is needed!

Hey @Snape

Your data structure is not clear through this thread. Please download the output bundle from JSON module you are trying to map data from and drop in this thread. It will help makers to provide you the solution.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
| Book Live Implementation
Visit us here
Youtube Channel

It’s ok I’ve figured it out, thanks for the help.

I realised that if I constructed a cleaner array using an iterator it would be easier to access it’s contents.

Hey @Snape

Glad to hear that you figured out on your own. Also you can group by using the variable names in array aggregator, that will produce different bundles in aggregator output and you can easily access using get and map function then.

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
| Book Live Implementation
Visit us here
Youtube Channel

Your array has a set of indices (that’s the number 1 when you look at the first element, number 2 for the second and so on).

So to access the first element of an array first(<arrayname>) will grab the first element for you. And then you can use pick() on that element which will just be a collection. It’s really important to understand what each function needs as input to properly function and experimentation with them using your structure will help you.

Can I suggest you take a look at the Make for Make Newbies video series? It will really help you out by studying various ways to manipulate data structures in Make.


Alex Sirota
Director of NewPath Consulting - we are :superhero: Make Heroes! :woman_superhero:t4:

:heart_on_fire: Check out my series of videos and scenario walkthroughs for Make Newbies :heart_on_fire:

My Solutions on Make Community

1 Like