Fields = ['Field1','Dollar Value'] FirstCursor = arcpy.da.SearchCursor(fcName,Fields) for Row in FirstCursor: totalPrice1 = (Row[1]) for Row in FirstCursor: if Row[0] == "Example 1": totalPrice1 += (Row[1]) del Row del FirstCursor SecondCursor = arcpy.da.SearchCursor(fcName,Fields) for Row in SecondCursor: totalPrice2 = (Row[1]) # Something needs to be changed here to get the first value correct for Row in SecondCursor: if Row[0] == "Example 2": totalPrice2 += (Row[1]) del Row del SecondCursor
Solved! Go to Solution.
Fields = ['Field1','Dollar Value'] totalPrice1 = 0.0 totalPrice2 = 0.0 TheOnlyCursorNeeded = arcpy.da.SearchCursor(fcName,Fields) for Row in TheOnlyCursorNeeded: if Row[0] == "Example 1": totalPrice1 += (Row[1]) elif Row[0] == "Example 2": totalPrice2 += (Row[1]) del Row del TheOnlyCursorNeeded
Fields = ['Field1','Dollar Value'] totalPrice1 = 0.0 totalPrice2 = 0.0 TheOnlyCursorNeeded = arcpy.da.SearchCursor(fcName,Fields) for Row in TheOnlyCursorNeeded: if Row[0] == "Example 1": totalPrice1 += (Row[1]) elif Row[0] == "Example 2": totalPrice2 += (Row[1]) del Row del TheOnlyCursorNeeded
Can't you just do something like this?:Fields = ['Field1','Dollar Value'] totalPrice1 = 0.0 totalPrice2 = 0.0 TheOnlyCursorNeeded = arcpy.da.SearchCursor(fcName,Fields) for Row in TheOnlyCursorNeeded: if Row[0] == "Example 1": totalPrice1 += (Row[1]) elif Row[0] == "Example 2": totalPrice2 += (Row[1]) del Row del TheOnlyCursorNeeded
for Row in TheOnlyCursorNeeded: if Row[0] == "Example 1": totalPrice1 += (Row[1]) elif Row[0] == "Example 2": totalPrice2 += (Row[1])
That doesn't make sense - can you post some of your data?
I have not tested further, but the only thing I can think of at this point is possibly an indention error with this block, corrected below (this time I am using tabs):for Row in TheOnlyCursorNeeded: if Row[0] == "Example 1": totalPrice1 += (Row[1]) elif Row[0] == "Example 2": totalPrice2 += (Row[1])