import arcpy, fileinput, os, string
from arcpy import env
env.overwriteOutput = True
env.workspace = "K:/Projects/Project Number/Points.shp"
fc = "shapefile.shp"
verification = arcpy.Exists (fc)
print verification
del verification
arcpy.Addfield_management (fc, "Field3", "DOUBLE", "", "", "", "", "", "", "")
fields = ("Field1", "Field2", "Field3")
with arcpy.da.UpdateCursor (fc, fields) as cursor:
for row in cursor:
row[0] = row[2+1]
cursor.updateRow(row)
del row
del cursor
Hello all. I am attempting to use python to add a new attribute table column to the existing attribute table columns of a shapefile. I have gotten this bit of code to work, as seen above and entitled "Field3." I want to populate values in this new field by adding the values of two other fields, "Field1", and "Field2". In other words, Field1+Field2=Field3. I think I am almost there, but I suspect that my "row[2] = row[0+1]" is incorrect. Any help would be extremely appreciated!