AnsweredAssumed Answered

Help with a loop

Question asked by wle0001 on Jun 26, 2012
Latest reply on Jun 26, 2012 by wle0001
Hey,

I need help with a while loop that's embedded in another while loop:
Boom = 79 whereClause = '"BoomName"' + " = '" + str(Boom) + "'" rows = arcpy.UpdateCursor(newFeature, whereClause)  row = rows.next()    while row:     line = textfile.readline()     while line:         linelist = line.split(",")         #TimeStep = linelist[TimeIndex]         LayerDepth = linelist[DepthIndex]         EffSM = linelist[Eff_SMIndex]         EffSM_Field = "EFF_SM_" + str(LayerDepth)         ActSM = linelist[ActSMIndex]         ActSM_Field = "ACT_SM_" + str(LayerDepth)         Water = linelist[WaterIndex]         Water_Field = "Water_" + str(LayerDepth)         Soil = linelist[SoilIndex]          row.setValue(EffSM_Field, EffSM)         rows.updateRow(row)         row.setValue(ActSM_Field, ActSM)         rows.updateRow(row)         row.setValue(Water_Field, Water)         rows.updateRow(row)          line = textfile.readline()      row = rows.next()


I'm trying to loop through a text file to update several fields of a specific type of feature. All the variables are well defined and the script runs without exceptions, however only for one row. Am I assuming something wrongly. I'm stumped. I would post the entire script but it's quite long. I guessing it's something simple I'm just not seeing. I simplified it to this and it works:

import arcpy  featureClass = "D:\\SampleGrid_1.shp" ID = 78 whereClause = '"BoomName"' + " = '" + str(ID) + "'" rows = arcpy.UpdateCursor(featureClass,  whereClause) row = rows.next() while row:     a = 5     while a < 20:         field = "EFF_SM_" + str(a)         row.setValue(field, 0.5)         rows.updateRow(row)         a += 5      row = rows.next()


Thanks for any advice.

Outcomes