[GIS] Split one field into 3 fields

arcgis-10.1arcpyattribute-tablefields-attributes

I need to split the values in a field according to what they represent to be able to do a join on the data. This is a cadastral polygon shapefile

As seen above I have a ID field that needs to be split into the following:

The ID consist of 21 digits where the first 8 digits represents the Town Code

The next 8 digits represents the ERF number

The last 5 digits represents the Portion number.

In there a way to easily split these into their own fields as I need to join a excel sheet to Town number, ERF and Portion.

For example:

C04100030000194800000

Will be split into their own fields:

TOWN: C0410003

ERF: 00001948

PORTION: 00000

I assume that this will be done with arcpy as I have over 50 000 records?

Best Answer

If the length of the ID field values is always constant I would recommend using either Field Calculator or Calculate Fields tool with python slices.

TOWN calculation:

!ID![:8]

ERF calculation

!ID![8:16]

PORTION calculation

!ID![-5:]