Change branch structure of tree with member index

Hello!

I’m manipulating a csv file to add another hierarchy in the tree structure based on rows that share a similar value. I start out with 7264 rows or so with 22 entries per row. {7264} N=22 . Based on unique values in the 0th entry, I want to create another level in the tree structure. So if there are 103 unique values for the 0th entry, I want to divide up those 7264 rows into a 103 branches/groups so that the structure is like {103;x} N=22, where x is the 7264 rows divided across 103 groups.

I thought the way to do it would be to use sets and member index to get the index of all the unique values, and then feed the indices into the tree branch component to alter the structure of the original data. However, there is no actual change to the data once I do this. (this is what I usually do for lists). I’ve googled a lot and tried out a bunch of tree components and I still can’t seem to find out how to do something simple like this… Would appreciate any help!

I have uploaded the csv and the gh file in case anyone wants to take a look.

Thank you!

blockchair2012.csv (1.3 MB) branchproblem.gh (19.8 KB)

If you reorganize your data tree from 7264 branches to 103, I have no idea how you would be able to maintain the item count per branch with 22.

If I understand you right, the item count per branch would vary because of the different duplicate count of unique 0th entry…

So, in the attached definition, I try to show you two different results. Which of the two do you want? You don’t want both?


branchproblem_re.gh (16.8 KB)

HS_Kim,

Thanks for your quick reply! I still want 7k branches, but just divided into those 103 unique values by branching. So 2 is partially what I want, with an addition of another partition list component to get N = 22 like this:

I’ve already gotten the solution, but I didn’t want to flatten the tree- it feels like the wrong thing to do. For the result that I want do you know if there is an easier way to do it? Before seeing your answer I wrote a python script using tree helpers and it was so much simpler but I thought I should learn the grasshopper way of doing it…

Thank you again!

branchproblem_re.gh (20.2 KB)

I’ve already unchecked ‘Maintain Paths’ and changed to ‘Renumber’, so you don’t have to use another partition afterward.

Thank you HS_Kim! :slight_smile: