I miss this function too, especially when attempting to port AML code to Python tools.Here is a python script that I called FrequencyWithCase to add back the functionality.It was not too hard, I can add the case ID as the records are read in a single pass updateCursor.# FrequencyWithCase.py
# do it properly ESRI
# 19 May 2010
# add a case item to the source table
# like Workstation
import arcgisscripting,sys,os
try :
table = sys.argv[1]
strFields = sys.argv[2]
except :
table = "e:/data/nzpost/paf2010/geopaf.gdb/pafpost"
strFields = "postcode;postcode_1"
gp = arcgisscripting.create(9.3)
casefld = "case"
ws = os.path.dirname(table)
tabname = os.path.basename(table)
gp.Workspace = ws
if len(gp.Listfields(table,casefld)) == 0 :
result = gp.AddField(table,casefld,"LONG")
print result.GetOutput(0)
else :
# name = gp.AddField(table,"case1","LONG")
print casefld,"Exists"
if gp.ListFields(table,casefld) == None :
raise Exception,"no case field"
seqfld = 'sequence'
if len(gp.Listfields(table,seqfld)) == 0 :
result = gp.AddField(table,seqfld,"LONG")
print result.GetOutput(0)
else :
# name = gp.AddField(table,"case1","LONG")
print seqfld,"Exists"
if gp.ListFields(table,seqfld) == None :
raise Exception,"no sequence field"
# make a dictionary with a combo key
# populate the source table as we go
# export the dictionary at the end
# make a tuple of all fields
# check if its in dictionary
# if it is increment counter
# otherwise add new entry
# retrieve number
# put number into index or back on table
#
dFreq = {}
lstFields = strFields.split(";")
print lstFields
cur = gp.UpdateCursor(table)
row = cur.next()
n = 0
ccase = 0
while row:
combo = []
for f in lstFields :
combo.append( row.GetValue(f) )
combo = tuple(combo)
if dFreq.has_key(combo) :
thiscase,freq = dFreq[combo]
dFreq[combo] = (thiscase,freq+1)
row.case = thiscase
row.sequence = freq+1
else :
ccase+=1
dFreq[combo] = (ccase,1)
row.case = ccase
row.sequence = 1
cur.UpdateRow(row)
## if n > 1000 :
## break
n+=1
row = cur.next()
del cur,row
print
print "case freq"
keytab = dFreq.values()
keytab.sort()
##for x in keytab:
## print "%4d %4d" % x
print len(dFreq),"cases"
# write out frequency table with case item
fTab = tabname+"Freq"
if gp.Exists(fTab) :
gp.Delete(fTab)
gp.CreateTable(ws,fTab)
gp.AddField(fTab,casefld,"LONG")
gp.AddField(fTab,"Frequency","LONG")
dscTable = gp.Describe(table)
dType = {"String":"TEXT","Integer":"LONG"}
for f in lstFields:
fType = dType[gp.ListFields(table,f)[0].type]
gp.AddField(fTab,f,fType) # may not be a "long" in general case
print f,"added to",fTab
cur = gp.InsertCursor(fTab)
for k in dFreq.keys():
## print dFreq[0],dFreq[1],dFreq
row = cur.NewRow()
row.case = dFreq[0]
row.Frequency = dFreq[1]
n = 0
for i in k:
##print i,n,lstFields
fld = lstFields
row.SetValue(fld, i)
n+=1
cur.InsertRow(row)
del cur,row
print "Done"