urows = arcpy.UpdateCursor(surveyFc) for row in urows: if 'C,' in updateRow.CODE row.setValue("HOST", "Confier") elif 'Hw,' in updateRow.CODE row.setValue("HOST", "Hardwood") else: row.setNull("HOST") urows.updateRow(row) del row, urows
Not sure how all that hokey looking "\" syntax keeps getting propogated (oh yeah, model builder and the Help pages), but it is generally completely unneccessary.The wildcards of *, %, or ? depend of course on the database (and GIS data format) you are using...This "should" work:#Select anything with a 'C,' string patern in it (Assuming FGDB/SDE format) and make the HOST field = 'Conifer' urows = arcpy.UpdateCursor(surveyFc, "CODE LIKE '%C,%') for row in urows: row.setValue("HOST", "Confier") #Note row.HOST = "Confier" also works urows.updateRow(row) del row, urows
#Select anything with a 'C,' string patern in it (Assuming FGDB/SDE format) and make the HOST field = 'Conifer' urows = arcpy.UpdateCursor(surveyFc, "CODE LIKE '%C,%') for row in urows: row.setValue("HOST", "Confier") #Note row.HOST = "Confier" also works urows.updateRow(row) del row, urows
surveyFc = 'Survey' query = '"CODE" LIKE \'*C*\'' urows = arcpy.UpdateCursor(surveyFc, query) for row in urows: row.setValue("HOST", "Conifer") urows.updateRow(row) del row, urows
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.