IdList = [] rows = arcpy.SearchCursor("INPUT_FILE") for row in rows: IdPlusOne = int(row.ID_FIELD) + int(1) IdList.append(IdPlusOne) del row, rows arcpy.MakeFeatureLayer_management("FC SELECTING FROM", "layer_lyr") i = 0 for Id in IdList: if IdList == 0: arcpy.SelectLayerByAttribute_management("layer_lyr", "NEW_SELECTION", "\"ID_FIELD\" = " + str(IdList)) i+=1 elif IdList >= 1: arcpy.SelectLayerByAttribute_management("layer_lyr", "ADD_TO_SELECTION", "\"ID_FIELD\" = " + str(IdList)) i+=1 arcpy.CopyFeatures_management("layer_lyr", "NEW_FEATURE_CLASS")
listRecords(myTable, 20, "MYFIELD = 1")
def listRecords(inputValue, numberOfRecordsToList = 25, whereClause = ""): "Lists field names and values in inputValue" if gp.exists(inputValue) == 1: fieldNamesList = [] fieldList = gp.listfields(inputValue) field = fieldList.next() while field: fieldNamesList.append(field.name) field = fieldList.next() searchRows = gp.SearchCursor(inputValue, whereClause) searchRow = searchRows.next() rowCount = 1 recordCount = int(gp.GetCount_management(inputValue)) if int(numberOfRecordsToList) > recordCount: numberOfRecordsToList = recordCount while rowCount <= int(numberOfRecordsToList): print "RECORD #" + str(rowCount) print "-" * 100 for fieldName in fieldNamesList: try: print fieldName + ": " + str(searchRow.getvalue(fieldName)) except: print fieldName + ": !?!" print "" print "" rowCount = rowCount + 1 searchRow = searchRows.next() del searchRow del searchRows print "" print "" print "LISTED " + str(numberOfRecordsToList) + " RECORDS" else: print "ERROR: " + inputValue + " does not exist!"
where = "FIELD in ('" + '\',\''.join(dataList) + "')"
IdList = [] for row in rows: IdPlusOne = row.ID + 1 IdList.append(IdPlusOne) del row, rows print IdList
import arcpy inFile = "e:/test.shp" # create searchcursor rows = arcpy.SearchCursor(inFile) #go through rows and print the values of Fields FIELD_A and FIELD_B for row in rows: print urow.FIELD_A print urow.FIELD_B del row, rows
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.