Firstly, thanks to ChatGPT for helping with this - credit where credit is due!
The below python code will return a feature with an attribute new_code containing each of the missing codes between the specified start and end ones. In you python caller, make sure you expose new_code
import fme
import fmeobjects
class FeatureProcessor(object):
def __init__(self):
pass
def has_support_for(self, support_type: int):
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM
def increment_code(self, code):
numeric_part = int(code[:4])
alpha_part = code[4:]
alpha_number = (ord(alpha_part[0]) - ord('A')) * 26 + (ord(alpha_part[1]) - ord('A'))
alpha_number += 1
if alpha_number >= 26 * 26:
alpha_number = 0
numeric_part += 1
new_alpha_part = chr(alpha_number // 26 + ord('A')) + chr(alpha_number % 26 + ord('A'))
return f"{numeric_part:04d}{new_alpha_part}"
def input(self, feature: fmeobjects.FMEFeature):
start = feature.getAttribute('postcode_van')
end = feature.getAttribute('postcode_tot')
curr = self.increment_code(start)
while curr != end:
feature.setAttribute('new_code', curr)
self.pyoutput(feature)
curr = self.increment_code(curr)
def close(self):
pass
def process_group(self):
pass