SearchCursor

1806
13
07-09-2020 01:38 AM
KristýnaSeimlová
New Contributor

I try to find a match of numbers in the first column and second column, if it finds the same number in second column, it writes the value of the first column into third column. Do you have any ideas? 

0 Kudos
13 Replies
JoshuaSharp-Heward
Occasional Contributor III

That really should run fine, I don't see how that's giving a syntax error, unless it doesn't like the indentation. In any case I defer to Dan's solution which is running the same thing but in one line:

!NADR_ID! if !NADR_ID! in !ABOVE! else None

0 Kudos
KristýnaSeimlová
New Contributor

It doesn't work for me, but thank you so much for your help anyway.

0 Kudos
JoshuaSharp-Heward
Occasional Contributor III

I realise that should be "NADR_GID" not "NADR_ID", where are you putting that line of code? It should be in the box below the code block, and the code block should be empty! If that fails, I'd be happy to take another look at the error message it gives.

Also I realised in your previous screenshot it's running as Python9.3, try the above line or my original solution with "Python" as the expression type just in case!

0 Kudos
DanPatterson
MVP Esteemed Contributor

Why do you need a search cursor? you can use the field calculator for that

python parser

!NADR_ID! if !NADR_ID! == !ABOVE! else None


... sort of retired...