Here's a quick and dirty solution using a Python script:
import fmeobjects
class AlphanumericCounter(object):
def __init__(self):
self.counter = 0
def counter_as_str(self):
a = self.counter // (26*9)
b = (self.counter - (a*26*9)) // 9
c = self.counter - (a*26*9) - (b*9)
return chr(65+a) + chr(65+b) + str(c+1)
def input(self,feature):
feature.setAttribute('id', self.counter_as_str())
self.counter += 1
if self.counter > (26*26*9):
raise fmeobjects.FMEException('Too many features!')
self.pyoutput(feature)
Each output feature will have a new attribute "id" that contains the counter.
If the number of features exceeds 6084 (id > ZZ9), it will terminate the translation with an error message. PythonCaller parameters:
And an fme solution, ignoring zeros
The NumToAlphaConverter from FME Hub could also be used here.
Here's a quick and dirty solution using a Python script:
import fmeobjects
class AlphanumericCounter(object):
def __init__(self):
self.counter = 0
def counter_as_str(self):
a = self.counter // (26*9)
b = (self.counter - (a*26*9)) // 9
c = self.counter - (a*26*9) - (b*9)
return chr(65+a) + chr(65+b) + str(c+1)
def input(self,feature):
feature.setAttribute('id', self.counter_as_str())
self.counter += 1
if self.counter > (26*26*9):
raise fmeobjects.FMEException('Too many features!')
self.pyoutput(feature)
Each output feature will have a new attribute "id" that contains the counter.
If the number of features exceeds 6084 (id > ZZ9), it will terminate the translation with an error message. PythonCaller parameters:
Close! The range of number should be 1 to 9 ;-)
Close! The range of number should be 1 to 9 ;-)
Ah, yes... But everyone knows that an array starts at 0, not 1
Close! The range of number should be 1 to 9 ;-)
But thanks for the tip, I've fixed the code above
Hello,
Thank for all yours replies and for your reactivity!
I choose to evacuate the 0 for a specific reason, that's why I ask only 1 to 9 thanks david_r for the adaptation of your code :)
Have a good day everyone!