AnsweredAssumed Answered

I cannot seem to get SelectLayerAttribute to work using Python?

Question asked by MarkHotz on Nov 20, 2019
Latest reply on Dec 14, 2019 by rpankevicius

I haven't written a Python script in years...so this is my first one in a LONG time.  With that in mind the issue could be more than one issue...I'm not sure.

 

I have a Python script almost working...just one more hurdle to complete and I'm ready to move on.  I'm running this script in ArcGIS Pro 2.4.2.  There is a sample feature class with 100 points, plus I created a list to extract values that will be passed to a "calc" function later.  The "list" I created was made using the Summary function in ArcGIS Pro, and I employ a cursor function as per below.  It too works really well and does what it's supposed to do.

 

However, this issue has me a little stumped, but I'm sure it's relatively easy to resolve...it could be a few different things, or it could be that Python isn't even capable to doing it they way I'm doing it.

 

The script does everything I want it to do except select the specific records in an attribute table.  I also have a CLEAR_SELECTION process that also runs immediately after this SelectLayerByAttribute string, but I don't know if it's doing anything either.  If I do this select manually it works without issue, but in a Python script it seems to have an issue.  Rather than select the specific group of records based on a unique identifier (MMSI) this SelectLayerByAttribute process selects the entire table for each iteration of the loop.  So when I calculate the field (in the next step) it just overwrites everything that was calculated in the previous iteration each time.  This process should update all of the blank fields/records found in the attribute table...and it too also works well manually.

 

So can anyone see what the issue might be here?  The code appears to be correct, so the does the syntax...what am I not seeing that will make this work properly?

 

 

 

Thanks

Outcomes