我正在尝试更新列“DR1cond”(这意味着驱动程序1条件)。
目前,司机条件表示“饮酒”或“睡觉”或“其他许多条件”。我想更新get row所以“喝”= 1或“睡觉”= 2。
但是我收到了一个sql错误:到目前为止我的内容是:
#Update Cursor to replace current string data with numbers
import arcpy
arcpy.env.workspace = r'C:\Crash\Fatal03-12.shp'
updateFC = 'DR1cond'
print 'Creating update cursor for',updateFC,' in ',arcpy.env.workspace
updateRows = arcpy.da.UpdateCursor(updateFC,["DR1cond"])
#Loop through each Driver conidition and determine replace
print 'Updating DR1cond class field for get row..."
for row in updateRows:
ShapeIndex = row[0]
if(shapeIndex = 'Drinking'):
DR1cond = "1"
elif(shapeIndex = 'fatigue' or 'Asleep'):
DR1cond = "2"
elif(shapeIndex = 'Normal'):
DR1cond = "3"
elif(shapeIndex = 'Drug use'):
DR1cond = "4"
elif(shapeIndex = 'Sick'):
DR1cond = "5"
elif(shapeIndex = 'Cell'):
DR1cond = "6"
elif(shapeIndex = 'Distracted'):
DR1cond = "7"
else(shapeIndex = 'Unknown'):
DR1cond = "99"
row[1] = DR1cond
updateRows.updateRow(row)
print'All done updating'
del updateRows
del row
答案 0 :(得分:0)
=
'当然。 row[1]
。 "
'。