try: Crow.setValue( 'Shape', arrayShape ) except RuntimeError: # This means setValue failed, i.e. 'Shape' is not a valid field name in Crow. # Put what you want script to do in this case here. pass
Do you ever revisit your older stuff and say, "What the #^$% was this guy thinking?
#Process: Now write the sorted records to the new FC message = "Sorting fields..."; showPyMessage() searchRows = gp.searchcursor(inputLayer, "", "", "", fieldSortString[:-1]) searchRow = searchRows.next() message = "Writing sorted records! Please wait..."; showPyMessage() insertRows = gp.insertcursor(outputLayer) recordCount = 0 inputLayerOidFieldName = dsc.oidfieldname origOidPopulateSuccessFlag = True while searchRow: #Process: Every 1000 rows give a message about the progress of the cursors recordCount = recordCount + 1 if divmod(recordCount,1000)[1] == 0: message = "Writing row = " + str(i) + "..."; showPyMessage() #Now read the old table and populate the new one insertRow = insertRows.newrow() for fieldName in inputLayerFieldList: try: #you can't write the OID, length, area, etc. fields if outShpDbfFlag == False: insertRow.setvalue(fieldName, searchRow.getvalue(fieldName)) if originalOidFieldName not in ["","#"," "]: try: insertRow.setvalue(originalOidFieldName, searchRow.getvalue(inputLayerOidFieldName)) except: origOidPopulateSuccessFlag = False pass else: insertRow.setvalue(fieldName[0:10], searchRow.getvalue(fieldName)) if originalOidFieldName not in ["","#"," "]: try: insertRow.setvalue(originalOidFieldName[0:10], searchRow.getvalue(inputLayerOidFieldName)) except: origOidPopulateSuccessFlag = False pass except: pass insertRows.insertrow(insertRow) searchRow = searchRows.next()
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.