List management and data matching - match Key of Excel and Project items

Hello Dynamo community,

First post here, so let’s see how it goes.

I am currently working with lists, trying to set type parameter values based on type keys. For keys and values I have an Excel file I read to create key and value lists.

The goal is to identify elements in the project carrying a specific value in a type parameter (key). Based on this key the elements should be sorted and the values from the Excel file assigned to another type parameter.

I did some search on the forum and found this workflow posted by Kulkul: http://dynamobim.org/forums/topic/dynamo-list-management-sorting-and-data-matching-with-sub-lists-help/

Solved that part - [It seems like it is what I want to do but I can’t get it to work because I can not find the “recorder” node in my Dynamo 1.0. Does anyone know if it’s from a custom package or maybe just renamed?
(I do have Lunchbox, Clockwork, ArchiLab, SpringNodes, SteamNodes)]

Below you find what the definition currently looks like. I think it’s mainly missing the “recorder” node. However I am happy for any advice on improvements as I am still struggling a bit to fully understand the list behaviour:

Thank you in advance,

Martin

Welcome to the community, @mrck!
A suggestion would be to search for the Reorder instead of the Recorder node and you’ll be better off. I’m sure someone can look into your script as well.

Jostein,
thank you for pointing that out.
Kind of a bad start with this stupid mistake.

Well … However now I got this part running, but still need to order the elements based on their key to assign the right values from the excel file to the elements retrieved from the project. As you can see the order of the keys from Excel and the ones I get from the project are different (key of project/excel in highlight nodes)

I tried messing around with sorting the keys (string to number and sorting). Couldn’t find a way to just order string alphabetically. But even if it worked, still I read more keys from the Excel file than are actually in the project.

Can I match just the ones existing in the project with the corresponding values from Excel?

Thanks,
Martin

Definition now looks like this:

No worries! :slight_smile: However if you can provide som example files that highlights your issue it would make it much easier to give advice, instead of rebuilding everything from skratch, and you probably will get help sooner!

Thanks Jostein,
your help is much appreciated.

It seems like I can not upload attachments as a new user, but here you can find the .rvt, .xls and .dyn files via dropbox: https://www.dropbox.com/sh/yn539uithsz8jrj/AADDiEh3klqbV8_Znaoh5tgYa?dl=0

In the end goal is to push several parameters based on the key value, but I guess that will then just be the same set.parameter routine copied several times. For the moment however I am just using columns A and B from the Excel file.

This example might help …

1 Like

Vikram,
thank you very much for your reply.
Your definition looks super straightforward and I just tried it.

Unfortunately I am getting an error. Error is because the length of the list of elements/keys from the project is longer than the list of keys from Excel. So in the end the indices just don’t exist in the key list I read from Excel.

Not sure if the fact that I am working with Type parameters makes a difference too. Any suggestion on how to fix the error or other solutions?

My suggestion was based on the premise that the key list will always be longer and contain all elements.

In your case you will now have to filter out elements that don’t find a place in the key list.

Vikram,

Your inital proposal works perfectly after I added key entries to the Excel setting values to 0 for those keys. This way I avoid the error and can set the right values, at least for the moment that will do.

I will look into your alternative solution to further improve the script.

Thank you very much!

Cheers,
Martin

1 Like

The alternate suggestion will not improve the script. :slight_smile:
I’d say extending the excel sheet to include all keys with associated dummy keys (as you seem to have now done) is the way to proceed.