My code has to check if a value in a shapefile attribute table belongs to a certain group of landuses. Below I paste my code:
cursor = arcpy.SearchCursor(buf_intersect)
fields = ["GTYS_Branc", "landuse", "landuse_1", "landuse_12", "landuse_13", "Shape_Area"]
for row in cursor:
book = xlrd.open_workbook("MyDirectory.xls")
first_sheet = book.sheet_by_index(0)
index = row.getValue(fields[0])
# Rural
if (row.getValue(1) == 'field') or (row.getValue(1) == 'farmland') or (row.getValue(1) == 'grass') or (row.getValue(1) == 'quarry') or (row.getValue(1) == 'paddock') or (row.getValue(1) == 'vineyard') or (row.getValue(1) == 'reservoir') or (row.getValue(1) == 'orchard') or (row.getValue(1) == 'greenfield') or (row.getValue(1) == 'allotment') or (row.getValue(1) == 'conservation') or (row.getValue(1) == 'moorland') or (row.getValue(1) == 'f'):
col = 2
# Suburban
elif (condition similar to the one above)
col = 3
And so on. When I run this code, I receive the following error:
Traceback (most recent call last):
File "Mydirectory.py", line 32, in <module> the first if line
File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\arcobjects\arcobjects.py", line 1100, in getValue
return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args)))
RuntimeError: ERROR 999999: Error executing function.
What can the reason be? May it be because I have too many conditions on my if statement?