Search for a value in "column A" of Excel and read the corresponding value in "column B"

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!

1 Like