POST
|
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
... View more
07-09-2020
03:51 AM
|
0
|
2
|
17
|
POST
|
Can you post another picture of what you ran this time?
... View more
07-09-2020
03:13 AM
|
0
|
4
|
70
|
POST
|
So in the original code I sent through, leave the field1 and field2 as they are (don't replace with your fields)! When you run myfunct(!NADR_GID!, !ABOVE!) that's substituting those values in there.
... View more
07-09-2020
02:55 AM
|
0
|
6
|
70
|
POST
|
This shouldn't be an issue from my understanding, the multiple numbers in the second column are all just strings joined by ";"s, so if the number from the first column is anywhere in the second column it will return it. Have you tried running it? If so maybe you can show me where it has returned a value that you didn't want?
... View more
07-09-2020
02:21 AM
|
0
|
8
|
70
|
POST
|
Hi Kristyna, I've done something quite similar to this in the past! In this case you don't actually need to use cursors, just the field calculator using Python will do! If you right click on the third field (BELOW) and go to "calculate field", select "python" for the expression type, put the following code in the code block: def myfunc ( field1 , field2 ) : if str ( field1 ) in field2 : return field1 else : return None Then in the box above the codeblock, put the following line my_func ( !NADR_GID! , !ABOVE! ) It should do exactly what you're hoping for it to do. Basically taking the first number, converting it to a string, looking for that sequence in the second field, then returning the first field's value if there is a match!
... View more
07-09-2020
01:54 AM
|
0
|
11
|
70
|
POST
|
Parfait! I should have added an if statement to check whether that category is in the dictionary anyway, see line 3 below. with arcpy . da . UpdateCursor ( fc , fields ) as cursor : for row in cursor : if row [ 1 ] in description_dict : row [ 0 ] = description_dict [ row [ 1 ] ] cursor . updateRow ( row ) Then it should just skip over those values!
... View more
07-08-2020
01:38 PM
|
1
|
0
|
124
|
POST
|
Hi Jared, Try passing the table's rest url into the table parameter, instead of the item. It should look something like " https:// <catalog-url> /<serviceName>/FeatureServer/0" with 0 indicating the index of the layer (if there's only one layer in the service, it will be 0).
... View more
07-08-2020
01:01 PM
|
0
|
2
|
124
|
POST
|
Interesting, let's make a slight tweak to that then: outname = os . path . join ( GDB , layer . name ) arcpy . CopyFeatures_management ( layer , outname ) just to be sure it's writing to the geodatabase that we want it to.
... View more
07-08-2020
11:30 AM
|
1
|
2
|
150
|
POST
|
Are the layer names the same as the names in the SDE? If so the following line should do the trick: arcpy . CopyFeatures_management ( layer , layer . name ) just below the selection.
... View more
07-08-2020
10:58 AM
|
0
|
4
|
150
|
Online Status |
Offline
|
Date Last Visited |
12-20-2020
08:40 AM
|