I am trying to use the field calculator in ArcMap 10.2 to fill an empty field based on the contents of two exiting fields usint this python script in the Pre-Logic Script Code.
def myfunc(legend,biltype):
if(legend == '0000 Manmade surface or step'):
return 'Manmade surface or step'
elif(legend == '0000 Multiple surface (garden)'):
return 'Garden'
elif(legend == '0000 Natural surface'):
return 'Natural Surface'
elif(legend == '0000 Path'):
return 'Path'
elif(legend == '0000 Railway'):
return 'Railway'
elif(legend == '0000 Road'):
return 'Road'
elif(legend == '0000 Road traffic calming'):
return 'Road Traffic Calming'
elif(legend == '0000 Structure'):
return 'Structure'
elif(legend == '0000 Track'):
return 'Track'
elif(legend == '0000 Unclassified (or broken)'):
return 'Unclassified (or broken)'
elif(legend == '0000 Unknown surface'):
return 'Unknown Surface'
elif(legend == '0321 Archway'):
return 'Archway'
elif(legend == '0323 Glasshouse'):
return 'Glasshouse'
elif(legend == '0377 Boulders'):
return 'Boulders'
elif(legend == '0379 Coniferous trees'):
return 'Coniferous Trees'
elif(legend == '0380 Coniferous - scattered'):
return 'Coniferous - scattered'
elif(legend == '0382 Marsh reeds or saltmarsh'):
return 'Marsh reeds or saltmarsh'
elif(legend == '0384 Nonconiferous trees'):
return 'Nonconiferous trees'
elif(legend == '0385 Nonconiferous - scattered'):
return 'Nonconiferous - scattered'
elif(legend == '0386 Orchard'):
return 'Orchard'
elif(legend == '0390 Rough grassland'):
return 'Rough grassland'
elif(legend == '0392 Scrub'):
return 'Scrub'
elif(legend == '0395 Upper level communication'):
return 'Upper level communication'
elif(legend == '0400 Inland water'):
return 'Inland water'
elif(legend == '0321 Building'):
if(biltype.startswith('Commercial, Education'):
return 'Education'
elif(biltype.startswith('Commercial, Emergency and Rescue Service'):
return 'Emergency Services'
elif(biltype.startswith('Commercial, Retail'):
return 'Retail'
elif(biltype.startswith('Residential'):
return 'Residential'
elif(biltype.startswith('Commercial, Industrial'):
return 'Industrial'
elif(biltype.startswith('Commercial, Hotels'):
return 'Hotels'
elif(biltype.startswith('Commercial, Community Services'):
return 'Community Services'
elif(biltype.startswith('Commercial, Medical'):
return 'Medical'
elif(biltype.startswith('Commercial, Leisure'):
return 'Leisure'
elif(biltype.startswith('Commercial, Offices'):
return 'Offices'
elif(biltype.startswith('Commercial, Utilities'):
return 'Utilities'
else:
return 'Building - Other'
else:
return 'error'
and then setting the field to equal
myfunc( !LEGEND!, !blpu_class!)
Where LEGEND, and blpu_class as the two field with the source data.
When I run the field calculator I get an 000989 Python syntax error:parsing error SyntaxError: invalid syntax (line 51)
This is the start of the nested if, but I can't work out what the problem is.