# Data Transformation with the Item Lists node - Harshil Agrawal

## Метаданные

- **Канал:** n8n
- **YouTube:** https://www.youtube.com/watch?v=37s019Xogbs
- **Дата:** 11.10.2021
- **Длительность:** 8:08
- **Просмотры:** 3,249
- **Источник:** https://ekstraktznaniy.ru/video/15766

## Описание

Learn about the various operations of the Item Lists node and how they can be used for data transformation.

## Транскрипт

### Introduction []

moving forward let's take a look at the item list node and learn a few tricks around that so i am gonna start with setting my screen see

### Item List Node [0:14]

wonderful i am assuming that you all can see my screen now so with the item list node as uh max already showed you how it works i'm gonna go through uh a deeper example and gonna show you each and every operations in there so the first example is similar to what mac showed so in here i love pokemon so i'm just making a api call to the 4k api if i execute this i am going to get some information okay let's see the meantime let me take a quick look at the chat right let's stop this reload it again try it once again all right so as you can see now we have we are getting a lot of information like the count the next endpoint that i should call if i want to get the further information the previous end point for this and then the result now i am only interested in the result for this so earlier it was using the function node but with the item list node i can specify that i want the results and if i execute this it just gives me the result so the result now contains the name and the url and it splits them into individual items so now over here we have hundred items and now if i want to process this hundred items i can add another node refer to these values and that particular node is going to iterate through all these items so this was a small example around the item list node the next is what if we want more information from this so for example if i execute this particular node which gives me some information over here so we have the json information sorry in the json object we get the id and we have the fields which contains the actual information but over here what i am interested in is get the category of all these particular uh json objects so the first thing i do is i specify which field i want to split so it's gonna be the categories because that's an array so if i execute this i get the all the categories for each of these individual items but i have the categories but i don't know which category belongs to which particular id or which particular object and that's where the selected or the fields or the all other field is helpful let's just take a look at what happens when i select all other fields now if i execute this it includes all the other fields from the previous node as well as it gets us this particular value over here that we have extracted in this node but as mentioned i am just interested in getting the id because i want to map that information in the next part of my workflow so i am going to select selected other fields and over here i have to just specify which field i want uh maybe let's just do id for now it's gonna be a quicker if i do id now you can see that i have got the json id as well as this so now i have an object that i want and then i can use it later on in my workflow so this was this split with a split out items operation now oftentimes you may want to aggregate all this information that is coming in right we earlier saw that we can split out all this information but what if we want to aggregate and bundle all this information into a single array that's where the aggregate without merge option is really useful so if i now execute this node we see that we have a category array which contains again all the categories now because these were all individual arrays it's now just creating an array of arrays all right just taking a look over here at this again now if you have made api calls and if you have taken a look at you know how api sends the response back it's generally not arrays of arrays it's simply a single array of maybe a string or an object so to do that what we can do now over here i have enabled the merge list option so what this will do is this will create a single array of all these options so now if you're making a call to an api if you want to pass on a single array to a particular node this is how you can do it without writing code

### Sorting [5:20]

the next one is kind of really interesting because we also have seen a lot of people doing this you know they want to sort uh sort the information coming in maybe in an ascending order descending order and they are not sure how they can do it using the function node and that's where again the item list node is really helpful now over here what i am doing is i am again making a call to the book api extracting the results and now i am selecting the short operation i am sorting this based on the field name and i want to do an ascending order so i selected the odd ascending if i want to do descending i'm going to select descending execute the node and now it does sorting for you so again it's just trying to help you out with you know not getting into the complexity of writing codes and giving you more of a visual cue of how you can do all these operations without code and the last one is around limiting these outputs so you get thousands of outputs from a particular node but in your response you won't only want to send me 10 of this incoming information so how can you do that so again the earlier word must you know write some functions and then uh limit those incoming values but now with the item list node you can limit the number of outputs that you want so over here i just want 10 items from the last right i just want the last 10 items that's why i selected keep if you want the first 10 items we can select first items we can even change this so let's just say we want only five items we execute this it returns only just five items and you can then pass on this information to the next node now over here you can combine all this together so let's just say we sorted this into ascending order and then we want to send the first five so you can have the sort operation and then you can connect the item list node with the limit operation and that's how you can move forward with this so i hope this kind of helps you understand how item list note can be useful now if you have again any feedback or if you want to you know uh let us know uh what kind of operations you think should be added in this you can always share it on the community forum and we would be happy to take a look at it and you know try to add more operations to the item list node
