I have a table in a geodatabase:
A column in that table lists a couple of feature classes that are in the geodatabase.
I want to make a loop on each name, count the number of rows in the attribute table of each feature class and store this value in a column of 'tableA'.
Here is what I've tried:
arcpy.env.workspace =r'C:\Users\user\Desktop\geodatabase\geoA.gdb' dataset = arcpy.ListTables("tableA") #the table needed is 'tableA' arcpy.AddField_management("tableA", "rows_count", "LONG") #create field with the count_rows for i in dataset: with arcpy.da.UpdateCursor("tableA",["file_name","rows_count"]) as cur: #the fields that needed for row in cur: try: nrow = arcpy.GetCount_management (row) #count each layer's rows row.setValue('rows_count', nrow) #fill the column with the values found cur.updateRow(row) #apply changes except arcpy.ExecuteError as e: print(e)
AttributeError: 'NoneType' object has no attribute 'setValue'
In the result, the
rows_count is null for all rows at the creation of the field.
What can be done here?
How the table looks:
file_name rows_count file1 null file2 null file3 ... null
In the main table, how to count the number of rows for each of these files and add store this vlue in a column ?
tableA file_name rows_count file1 0 file2 12 file3 1 ...
file1,file2, etc are actual feture classes in the
rows_count are the number of rows in each file.