kmeseck

Using one element of a large field for some math with python

Discussion created by kmeseck on Aug 28, 2013
Latest reply on Aug 28, 2013 by rfairhur24
I have a ridiculously long .dbf (around 15 million rows). One of my columns contains four values separated by commas. I tried the easy way, which was to separate them using the field calculator, but because there's so many rows the field calculator consistently stopped running after it's was 2/3 the way done. Sample of this column:

backpresdi
1,1,1,2345.6
1,1,2,3533.8
1,1,3,4440.5
1,1,4,3892.6
1,1,5,1292.0


I decided to jump ahead and do some python (I'm quite rusty) just using the fourth element (element 3) to do some calculations without separating it out into a new column. I'm having some issues though, maybe I can't do it this way? I am getting a "list index out of range" error. I feel like I may be missing something obvious here.

import arcpy

from arcpy import env
inputTable = arcpy.GetParameterAsText(0)

fields = ("Gauss", "backpresdi")

rows = arcpy.da.UpdateCursor(inputTable, fields) #all values from the table


#selecting the fourth element from the backpresdi column and doing some math

for row in rows: #simple for loop 
    row.Gauss = exp( - ((row.backpresdi.split(",")[3])^2)/(2*6500^2))
    rows.updateRow(row)


del row
del rows

Outcomes