Thursday 4 May 2017

arcpy - Using Python to count records and show difference in ArcGIS Desktop?


I'm trying to find an example of a python script for ArcGIS 10.1 that will get count of a feature class (FC) in my ArcSDE and get count of a FC in an incoming file geodatabase update and then write the difference to a log file. We get monthly updates from a vendor. For instance, wells FC, and want to be able to compare record counts and log diff (a-b=C). Right now I have a script that will record start time, get count, truncate, append, rebuild index.




Answer



Here's a one-liner for getting the count of records in a specific FC or table:


count = sum(1 for row in arcpy.da.SearchCursor(r'C:\PATH\TO\FC', ['OID@']))

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...