AnsweredAssumed Answered

Iterate and Add Values from many fields

Question asked by jacobrodel on Mar 4, 2016
Latest reply on Mar 5, 2016 by Dan_Patterson

Can somebody please help me, I have been struggling with this part of my script for hours now.

 

I need to list the precip fields from my point feature class:

Create empty MaxValue list

For every record in my attribute table:

Add up(SUM) values from first 6 fields [0]-[5] and append value to list (by record line)

Add up(SUM) values from next group of 6 fields [1]-[6] and append value to list

Add up(SUM) values from next group of 6 fields [2]-[7] and append value to list

Loop to end of field list making sure it does not error at the end if it is not a full group of 6 records

After I have a MaxValue list it finds the MAX from that list and adds that to the MaxPrecip field. (I think I can get this part its just incrementally iterating over and summing groups of fields by record that is killing me)

Repeat for every point, there may be thousands of points and 20 or 120 fields. 

 

>>> PrecipFields = [f.name for f in arcpy.ListFields("asciiPoints","*")]

>>> with arcpy.da.UpdateCursor("asciiPoints",PrecipFields) as cursor:

...     for row in cursor:

...         MaxValue = []

...         i = 0

...         for i in range(len(PrecipFields)):

...             v = row[i] + row[i+1] + row[i+2] + row[i+3] + row[i+4] + row[i+5]

...             Val.append(v)

...             i = i+1

 

Am I even close? 

Thanks

Outcomes