# Python script version
import fmeobjects
import re
AttrName = ['field0', 'field1', 'field2', 'field3']
def sortAttributes(feature):
v = {}
for n in AttrName:
s = feature.getAttribute(n)
if s and re.match('^.+_.+$', s): v[s.split('_')[-1]] = s
i = 0
for k in sorted(v.keys()):
feature.setAttribute(AttrName[i], v[k])
i = i + 1
for j in range(i, len(AttrName)):
feature.setAttribute(AttrName[j], '')
No comments:
Post a Comment