import arcpy arcpy.env.workspace = r'C:\WorkSpace\Projects\Code\Special Request\Copeland\src\SageGrouseTestCode.gdb' parcelIDTable = 'ParcelNBTable' lekFC = 'LekParcelFC' try: parcelRows = arcpy.SearchCursor(parcelIDTable, "", "", "ParcelNBTable_PARCELNB", "") for parcelRow in parcelRows: print 'Parcel Number: %s' %parcelRow.ParcelNBTable_PARCELNB try: if len(parcelRow.ParcelNBTable_PARCELNB) > 0: expression = '"PARCELNB" = ' + "'" + parcelRow.ParcelNBTable_PARCELNB + "'" lekRows = arcpy.SearchCursor(lekFC, expression, "", "", "Complex A") for lekRow in lekRows: print '\tLek complex name: %s\tCount %i' %(lekRow.Complex, lekRow.MAX_MostRecentPeakCount) except: print arcpy.GetMessages(2) except: print arcpy.GetMessages(2) print 'fin'
in_tablePath = arcpy.GetParameterAsText(0) # full path to input table (includes name) out_tablePath = arcpy.GetParameterAsText(1) # path to output table out_tableName = arcpy.GetParameterAsText(2) # name of output table featureClass_dataset = arcpy.GetParameterAsText(3) # path to the .gdb (or Folder if .shp) of the feature classes if not arcpy.Exists(in_tablePath): # check in case table doesn't exist... arcpy.AddError('Table, ' + in_tablePath + ', does not exist...') else: # table does exist, continue arcpy.AddMessage('Using table: ' + in_tablePath) # let the user know the table path arcpy.CreateTable_management(out_tablePath, out_tableName) # create the output table... arcpy.AddField_management(out_tablePath+'\\'+out_tableName, "outputData", "DOUBLE") # add a field to the new table arcpy.CalculateField_management(out_tablePath+'\\'+out_tableName, "outputData", 0, "PYTHON") # calculate its value as 0 for now... (optional) rowList = arcpy.SearchCursor(in_tablePath) for row in rowList: # for every row parcelID = row.getValue("parcelid") # i.e. if the feature classes are in C:\GIS\Data\parcels.gdb, and parcelID = 7 # will return the feature class C:\GIS\Data\parcels.gdb\7 featureClass = featureClass_dataset + '\\' + str(parcelID) # make sure parcelID is changed to a string as well if not arcpy.Exists(featureClass): # check in case feature class doesn't exist... arcpy.AddError('Feature Class, ' + featureClass + ', does not exist...') else: # feature class exists, continue... ## Do calculations here... # don't know how you want to write the results, you could use an insert cursor # or copy selected rows to a new table (or the new table...)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.