Working on ArcMap Desktop 10.5; the file in question lives in a file gdb. I have a polygon layer with a field of full property addresses (string) from which I need to extract ONLY the unit number, to be populated in a new blank field STUNIT (string). The addresses are all different lengths depending on presence of street direction, etc. so my addresses, for example, could look something like this:
1 BOXER ST UNIT 7A FARMINGTON
945 WILD TURKEY XING UNIT 116 TURTLE ISLAND
52 W CLAIRMONT DR UNIT J17 EASTHAVEN
I have already performed a selection to return only records which contain the word "UNIT", about 4000 records. My goal is to populate my STUNIT field using the python parser in field calculator, with ONLY the "word" directly following UNIT. I have tried variations of the split function which looks something like this
but, without fail, get the following error messages:
- Whitespace is not allowed at this location
- This row contains a bad value (for both the shapefile itself and the field I tried to populate)
I have checked for spaces within/outside of the function but none exist. I have also tried a variant where I use find and replace to add a * to the end of the word "UNIT" and use the * as the delimiter in the function, but get identical results. Can a word in a string field be used as a delimiter for the split function in Arcpy? If so, what am I doing wrong/if not, is there another workaround that does not require a return on the nth object?
I have several years experience with ArcGIS but relatively new to python.