Is there a specific way to assign the object that for example row[0] returns in a SearchCursor
to a new field name? I mean how to write it in add field syntax, this doesn't work: arcpy.AddField_management(fc, str(row[0]), "DOUBLE")
. That field is a string field by the way. I can't find such an example anywhere online. Here is the code:
import arcpy
fc = "C:/Users/salahmed/Documents/ArcGIS/Test.shp"
myList = []
myList2 = []
myList3 = []
myField = ["USE"]
myFields = ["USE", "Stadteil", "PERCENT"]
with arcpy.da.SearchCursor(fc, myField) as cursor:
for row in cursor:
if row[0] in myList:
pass
else:
arcpy.AddField_management(fc, str(row[0]), "DOUBLE")
myList.append(row[0])
del cursor