List.Insert Node - Empty list Issue

Hello Forum

Please could I ask for your help? I am looking to insert a list into another at the index values - using the List.Insert node. It is working, except when I have an empty list it fails to bring in the list item - in this case index 2 (red box).


Could I ask for any suggestions to allow through the indexes with empty lists? I have tried using the ReplaceEmptyLists node from Clockwork, but this does not resolve the issue.

Any help would be greatly appreciated.
Thanks
Tim

“Empty List” An example to filter:

Thank you very much for the suggestion. I need to keep the list structure the same, so it will hopefully feed in sheet at index 2. If I use FilterByBooleanMask I will lose the structure? I will give it a try though. Thank you for the suggestion.

Hi Tim,

The issue you have here is to do with the list structure of the indexes you wish to insert at and the fact you’re trying to insert nested lists themselves.

For example, in the image above where I replicate your error you can see it says 'the index is out of range". This is because you’ve created an index for each item in the lists you’re inserting, (0,0,2,0) whereas you only need 1 index per list you’re inserting (you were correct in assuming you need to create an index to insert that empty list at though because if you clean them out first list 3 doesnt get pulled through still, which I assume is something to do with just how the node works).

.

To explain/follow the logic of the error through: The list insert first correctly inserts ‘insert1.1 & insert1.2’ at index 0 in list 1 because they are a nested list themselves. So then because only the first ‘0’ in the index list has been used it inserts ‘insert 2.1’ at index 0 in list 2 of the soruce list.

This leaves it trying to insert the empty list at index 2 of list 3 in the source list which is what forces the error (list 3 does not have an index 2).

As seen below, if you change the indexes so that instead of 1 index per item you have 1 per list (0,2,0) it does as you believed it should. It’s then a simple process of cleaning the list after the remove the empty list

This might mean a re-think of how you’re defining those indexes but I’ll leave that up to you.

Hope that makes sense,
Jake

1 Like

Hi Jake

This is fantastic help thank you very much for your explaination of the logic. Yes I see now that the indexes do not match where the elements are expecting due to the indexes inserting the elements together rather than individually, I was hoping that insert 1.1&insert1.2 would be inserted separately based on the separate index value (just happens both are 0). But then for insert2.1 this would go into list 1 at index 2 (as I have it).
I will try working on the list structures so they correlate before going into the List.Insert node.

Thank you very much again for your help with this.
Cheers
Tim

Hi Jake

Thank you again. I have done a test by isolating the 0 index of each list, and tested to see whether the List.Index node would work on each item in the list, but it appears to only take the first item. I have shown the elementIDs so you can see the items it brings in.

Maybe this makes sense, as with the example I did of asking it to insert 2 items at the same index value, then there is not enough information to know what to do if they are within the same index.

Could you suggest any ideas of how I could go about this but keeping the list structures the same?

Many thanks again
Tim