VLOOKUP Function in Grasshopper - Data Tree Management/Manipulation

Thank you for taking the time.

Context (Picture attached to help clarify):

I am using TT Toolbox to read from Excel, and Tekla to pull UDAs from a Member into Grasshopper.

I have an Excel sheet with 11 Columns and 6 Rows, where the 1st Row is a header.

I have a UDA (Value, Index) that I’m pulling from my Tekla Model, BCF1, which is also present in the first column of the Tree that I’m pulling/creating from Excel.

I need to essentially VLOOKUP this UDA that I’ve pulled in and find which Row aka Branch it is associated with in the Data Tree I pulled/created from Excel.

I then need to pull that Branch Value to be used in a filter for which Branch’s Values in the Tree I will be using for my component.

I hope this makes sense.

What are your recommended solutions, WITHOUT writing back to Excel and using the vlookup function there?

does this help:

if you already know in advance the item you are looking for is in at a fixed index in your lists, you can maybe just member index it

here, because the text you are looking for is always at index 0, List Item (A) creates a sort of simplified tree with only items at index = 0 for each existing branch

then Member Index (B) identifies -for each branch- at which index your text is eventually present, which means you will get all your branches, with a single “zero” item if the text was found

at that point you can Clean Tree (C) with Remove Empty option = True, in such a way it deletes all the branches that do not contain any item, which will create a tree where only branches containing a zero (aka containing your text) are present

and as last step Tree Stats (D) retrieves the path of the branches which are still present, which are the branches that contain the value you were looking for

Search_in_branches_at_given_index.gh (14.9 KB)

by the way, this definition at the current state will allow to search for a single text, and will fail for multiple ones


a maybe faster and smarter way is to create a Dictionary using Key Value search, where the Keys are -for each branch- the text at index=0 and the Values are the relative tree Paths:

Search_in_branches_at_given_index_Key_Value.gh (17.7 KB)

this does really sound as the better way to do the same thing as above :upside_down_face: