Hi All, I’m a beginner in Dynamo, trying to create a program to size pipes based on the fixture units. Could you please tell me which node to be used for searching for a value in “column A” of Excel and read the corresponding value in “column B”…?
First of all: you’re going to want to simply load in the excel sheet by using a File Path node and attaching it to a Excel.ReadFromFile node.
With that you simply load in the entire excel page. After you’ve done that it might be the moment to start looking how to deconstruct it and read out the right values.
Hi, you need to get to know with the basics of looping in python. Try out this video. It also explains the basics of Revit API and working with python nodes in dynamo.
For this particular case I can help you with a prepared example. Study it hard and watch the video. It will help you much in future.
val = IN[0]
A = IN[1]
B = IN[2]
new = []
for i in range(len(val)):
if val[i] in A:
n = A.index(val[i])
new.append(B[n])
else:
new.append('Not in the list')
OUT = new
To use this script create a new “python script” node with 3 input slots. The first one is you values. The second one is column “A”. The third one is column “B”. This script reads the values and looks them up in column “A”. If the element is in the list, it takes the corresponding value from the column “B”. If not - the script returns string “Not in the list”.
Welcome to our community!))) And a piece of advice for the future: we don’t simply ask how to do this or that here. Firstly we try to create something, then we share our script with others and ask about the problems and errors that we have. Good luck!
This can be done with a simple FilterByBoolMask. Get your excel data into Column A values and Column B values. Use whatever conditional statement you’re using to check Column A. This will return a True/False value for each item. Use the True/False values as your mask for Column B.
I agree with @Nick_Boyts - no need to go python on this exercise as it’s fairly straightforward with OOTB content and some lacing. A “Dynamo 201” exercise.
That’s an easy fix, the reason it worked for me and not for you is because I still have “Size” in my list, the index 6 does not mean the sixth value on the list, but the value with index 6, so that’s the seventh value. You could simply add a code block after the fixture units subtracting 1 of all of these values (edit: that’s the indices, so the lower list).