General Function Failure With Cursor in Python Script

1623
15
09-11-2024 12:58 PM
AdamTerrell
Occasional Contributor

I AM NOT A DEVELOPER. Zero Python experience.

I have taken over a role where my predecessor automated nearly everything with Python scripts. To this point, I have been able to maintain and/or fix various scripts using ChatGPT.

I have a script designed to update water meter usage and plot new meters.

The script runs fine and updates the water meter usage, but it fails when it reaches the block of code that involves a cursor to look for new meters.

After days of attempting to solve this myself with the assistance of ChatGPT. I figured I would, at the risk of looking like a fool, reach out here.

AdamTerrell_0-1726083556516.png

0 Kudos
15 Replies
AdamTerrell
Occasional Contributor

Thank you. I have not utilized the repair geometry tool. The table is an export we are given from Muller on a daily basis. I will have to read the documentation you provided and see what's up.

0 Kudos
AdamTerrell
Occasional Contributor

I have all the file permissions I need. I am on a more updated version of Pro than my college. I am using a 3.11 "interpreter" and he is using 3.9.

Is there a way to install an older version of this "package" or "interpreter". All I know is when I choose an interpreter in PyCharm I navigate to C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe

I am desperate. I have no clue what version of Pro my predecessor had when he created this script, but I know what my colleague is using works.

0 Kudos
AdamTerrell
Occasional Contributor

AdamTerrell_0-1727098405098.png

I do know there is some null geometry that is ignored in the beginning of the script, when it is creating table to points.

 

0 Kudos
AdamTerrell
Occasional Contributor

Latest run with the added code. Not sure what the new code is doing. Nothing prints.

AdamTerrell_0-1727103536848.png

 

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Basically it's failing in the cursor.

Just for funsies, replace the "field_to_compare2" in what we added with another field like "OBJECTID" (assuming you have OBJECTID in that table).

Then, after that fails (probably will), try adding Repair Geometry on featureclass2 immediately before the cursor and see if that fixes anything.

0 Kudos
AdamTerrell
Occasional Contributor

I did look at the repair geometry documentation you provided. These are just point features and some null values are ignored when converting the table to points. I do not belive ObjectID is in the csv, but it is probably in one of the joined tables, which I thought is what the cursor is looking through.

 

0 Kudos