sreaves

Create Sequential Numeric ID in Groups

Discussion created by sreaves on Apr 11, 2011
Latest reply on Apr 11, 2011 by sreaves
I have a set of records:
OID,Type
1,A
2,B
3,A
4,B
5,C
6,C
7,B
8,B
9,A

I'd like to use a python script to add a sequential unique ID by type...
OID,Type,Type_Num
1,A,1
2,B,1
3,A,2
4,B,2
5,C,1
6,C,2
7,B,3
8,B,4
9,A,3

So far i've attempted looping through a list of types but with only partial success and i'm convinced i'm way off base as evidenced by code below...
rec=0
L=["A","B","C"]
def doit (Type) :
  for name in L :
    while Type == name :
      global rec
      rec = rec + 1
      return rec
    rec=0
__esri_field_calculator_splitter__
doit (!Type!)

My ultimate goal is to reference my records in the fashion A1, A2, A3, B1, B2, B3 etc.  Any thoughts or suggestions would be much appreciated.  Obviously i'm VERY new to Python.

Outcomes