Hi @senteria, If you know which attributes should be integrated into the "other" field, you can just create desired value with AttributeManager (or AttributeCreator or StringConcatenator), as in:
Hi @senteria, If you know which attributes should be integrated into the "other" field, you can just create desired value with AttributeManager (or AttributeCreator or StringConcatenator), as in:
Thank you so much, Takashi! The answer was in front of me all along but i have been staring myself blindly. I was using a schema reader and had split the attribute names from the source table with a feature merger. I was trying to automate it by having it read the structure and automatically combine the attribute names that do not match the schema be put into a new attribute. Thanks again for the solution. I am not sure what i was attempting is even possible.
Hi @senteria, If you know which attributes should be integrated into the "other" field, you can just create desired value with AttributeManager (or AttributeCreator or StringConcatenator), as in:
You can use the Schema Reader to read schema from the source table and the template table, create a list attribute (e.g. "_other{}.name") containing attribute names that should be aggregated into the "other" attribute, and then merge the list to every data feature unconditionally, with this workflow for example.
After that, however, I think you will have to write a script (Python, Tcl or so) to create the "other" attribute.
PythonCaller Script Example:
def aggregateOthers(feature):
items = p]
attrs = feature.getAttribute('_other{}.name')
for attr in attrs:
value = feature.getAttribute(attr)
items.append('%s:%s' % (attr, value))
feature.setAttribute('other', ', '.join(items))
You can use the Schema Reader to read schema from the source table and the template table, create a list attribute (e.g. "_other{}.name") containing attribute names that should be aggregated into the "other" attribute, and then merge the list to every data feature unconditionally, with this workflow for example.
After that, however, I think you will have to write a script (Python, Tcl or so) to create the "other" attribute.
PythonCaller Script Example:
def aggregateOthers(feature):
items = E]
attrs = feature.getAttribute('_other{}.name')
for attr in attrs:
value = feature.getAttribute(attr)
items.append('%s:%s' % (attr, value))
feature.setAttribute('other', ', '.join(items))
Thank you so much Takashi, this works precisely as I hoped for! Do you per chance know how I can make it so the 'other' attribute string only contains attributes that are filled and not empty? i.e. In case 'grains' has no value, I would like it to be left out in the string. I think the solution for this lies in the python script where it needs a clause line. Unfortunately I have yet to learn python scripting. I suppose it's something along the lines of 'if attribute value has a value' -> combine.
Hi @senteria, If you know which attributes should be integrated into the "other" field, you can just create desired value with AttributeManager (or AttributeCreator or StringConcatenator), as in:
This script combines "other" attributes except null, missing, empty, and numeric 0. If it's sure that every attribute never stores numeric 0, this script would be enough.
def aggregateOthers(feature):
items = <]
attrs = feature.getAttribute('_other{}.name')
for attr in attrs:
value = feature.getAttribute(attr)
if value:
items.append('%s:%s' % (attr, value))
feature.setAttribute('other', ', '.join(items))
However, if the attribute might contain numeric 0, a bit more strict conditional expression would be required, like this.
def aggregateOthers(feature):
items = r]
attrs = feature.getAttribute('_other{}.name')
for attr in attrs:
value = feature.getAttribute(attr)
if value != None and value != '':
items.append('%s:%s' % (attr, value))
feature.setAttribute('other', ', '.join(items))
This script combines "other" attributes except null, missing, empty, and numeric 0. If it's sure that every attribute never stores numeric 0, this script would be enough.
def aggregateOthers(feature):
items = f]
attrs = feature.getAttribute('_other{}.name')
for attr in attrs:
value = feature.getAttribute(attr)
if value:
items.append('%s:%s' % (attr, value))
feature.setAttribute('other', ', '.join(items))
However, if the attribute might contain numeric 0, a bit more strict conditional expression would be required, like this.
def aggregateOthers(feature):
items = p]
attrs = feature.getAttribute('_other{}.name')
for attr in attrs:
value = feature.getAttribute(attr)
if value != None and value != '':
items.append('%s:%s' % (attr, value))
feature.setAttribute('other', ', '.join(items))
This is perfect and precisely what I was looking for. Thank you very much for your time and help. Greatly appreciated.