2

I have bunch of home adresses which contain home number and subnumber, for example Street of J.F. Kennedy 1005A. Now I want to split this into two fields out of home number, one for main number and one for subnumber.

How to split '1005A' and get '1005' in one and 'A' in another field somehow using the 'split command' in Field Calculator?

5
  • Is it always four numbers and a single letter? Commented Aug 16, 2017 at 9:21
  • 3
    Are you using the field calculator of ArcGIS Desktop, QGIS or something else?
    – PolyGeo
    Commented Aug 16, 2017 at 9:26
  • Yes, 1005 and A. It's not always four numbers, sometimes is just 2 or 3.. but mostly is a single letter. I'm using field calculator of ArcGIS Desktop Commented Aug 16, 2017 at 10:15
  • Welcome to GIS SE. As a new user, please take the Tour. Boolean "Is it possible?" questions are of little value, since the answer is always, "Yes." Please Edit this question to specify the exact GIS software, restructure this to a "How" query, and contain the code you have attempted so far.
    – Vince
    Commented Aug 16, 2017 at 10:23
  • Plesse Edit the question in response to requests for clarification. It's not fair to those who would answer to need to mine the comments for critical information.
    – Vince
    Commented Aug 16, 2017 at 10:24

1 Answer 1

2

You can do this using Python code and the UpdateCursor which is like a more powerful Field Calculator. The re module is doing the splitting of the numbers and letters.

Add the Feature Class to ArcMap, add the two fields as text (or modify the code to convert into other data types) and execute code in the Python Window. You need to change name of the feature class and fields in the code to match your data (yellow below):

enter image description here

import arcpy,re
fieldlist=['Adress','Main_number','Subnumber']
with arcpy.da.UpdateCursor("Points123",fieldlist) as cursor:
    for row in cursor:
        row[1],row[2]=re.findall(r'[A-Za-z]+|\d+', row[0].split()[-1])
        cursor.updateRow(row)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.