`arcpy.da.SearchCursor` is returning unpredicable results.
I have an empty table in pro. I just deleted it and saved it, so I know it's empty.
When I then `SearchCursor` on that table it returns results! But the table is empty!
cur = arcpy.da.SearchCursor(full_table_path, field_names)
for c in cur:
print(c)
I wanted to use this function to check for duplicates before inserting, but it seems highly unstable. Is there any way to make it pick up recent changes?
Whatever the issue, if the table is not actually empty but just shows empty, or if it's the function, I just need it to work accurately.
It's a file table, so maybe this is why?
Just out of curiosity, is your project setup to automatically allow edits to happen when the project is opened up and feature or table attributes can be updated? This could be causing your issue if the data source is something other than a feature class or table in either an sde or gdb.
The other thing you mentioned is that you are working with a file table. If you could please explain that further then it might be easier for anyone or any of us to help you with your given situation?
It sounds like your file table might be either an excel spreadsheet or some other table. If that is the case have you tried importing the table and see if the results are the same. You can use python to read other tables like excel but trying to run any edits on those tables or pull information from them could result in less than desirable behaviors. I have run into similar situations using external tables and usually importing them and then running python code on that table usually fixes the issue.
It is often best to run python as a standalone script using the modules that are designed to read those file types instead of bringing them into pro. @HaydenWelch may be able to affirm this or have a different take than mine.