Created
February 7, 2019 19:55
-
-
Save tonjadwyer/5bafe3a2b2cdb4f7a1fd4273fe6235dc to your computer and use it in GitHub Desktop.
ArcGIS-Python WIndow-Compare feature class fields using sets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l1_name = [] | |
with arcpy.da.SearchCursor(r"layer1", ("OID@", "Name")) as cursor: | |
for row in cursor: | |
l1_name.append(row[1]) | |
l2_name = [] | |
with arcpy.da.SearchCursor(r"layer2", ("OID@", "Name")) as cursor2: | |
for row in cursor2: | |
l2_name.append(row[1]) | |
# find names in source not in target | |
l1_not_in_l2 = list(set(l1_name)-set(l2_name)) | |
# if you want to use it result in a def query | |
# make an in clause | |
l1_not_in_l2_wrap = ["\'{}\'".format(x) for x in l1_not_in_l2] | |
l1_not_in_l2_in = ",".join(s_a_wrap) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment