Solved! Go to Solution.
def losemunitype( name): lsttypes = ['County', 'Parish', 'Borough', 'Municipality', 'Census Area', 'City and Borough'] for losetype in lsttypes: if losetype in name: return name.replace(losetype, '') return name
In python:!Name!.split()[:-1]
Thanks raymondhuang - I unfortunately get an error message saying "No features found. Could not verify expression."
Any ideas? Thanks again.
[Name].split()[:-1]
[Name].rstrip(" Country")
In vbscript: Left([Name], Len([Name])-6)
Basically this prints anything on the Name field and ignoring the last 6 character, which is dropping off the " county"(note the space character).
Hope it helps!
Cheers,
Raymond
[Name].rstrip("Census Area").rstrip("Municipality").rstrip("Borough").rstrip("City and Borough").rstrip("Parish").rstrip("County").rstrip()
There are a lot of different ways to do this, but I would use this:[Name].rstrip("Census Area").rstrip("Municipality").rstrip("Borough").rstrip("City and Borough").rstrip("Parish").rstrip("County").rstrip()
The last .rstrip() gets rid of any spaces at the end of the new string.
def losemunitype( name): lsttypes = ['County', 'Parish', 'Borough', 'Municipality', 'Census Area', 'City and Borough'] for losetype in lsttypes: if losetype in name: return name.replace(losetype, '') return name