AnsweredAssumed Answered

Add trailing zeros to field

Question asked by CCweedcontrol on Feb 1, 2017
Latest reply on Feb 2, 2017 by blake.terhune

I have a table BuildingTable with building info. There is a field called "Build_num" with characters like B37828 or B2898101 or R29499010C or R29499010C2 that i need to join to a shapefile but the the Shapefile BuildNum has a max of 11 characters like so B3782800000 or B2898101000. so i can't join the table to shapefile.

 

How can update the BuildingTable field "Build_num" to add trailing zeros to that field?

 

I tried the following, i added a new filed to insert the new Build numbers with the trailing zeros but nothing happened.

 

import arcpy

 

fc = "BluidingPermitsTable"
fields = ('Build_num', 'BuildNum')
with arcpy.da.UpdateCursor(fc, fields) as cursor:
    for row in cursor:
        if row[0] <= 11:
            row[1] = '0' + str(row[0])
            cursor.updateRow(row)

 

Thanks.

Outcomes