Have you looked at the BulkAttributeRenamer?
Have you looked at the BulkAttributeRenamer?
Or maybe I'm misunderstanding -- maybe "AttributeName" isn't a constant, but rather the actual name of the attribute? Example from:
a1=aa
b1=bb
To
a1|aa
b1|bb
Is that it?
Apologies @david_r for not being clear. For each of the 60 columns, I would like to append the name of the attribute to every value under that attribute.
I would use the AttributeExploder to get _attr_name and _attr_value attributes on the feature, and then a StringConcatenator to get the final result of _attr_name|_attr_value.
I would use the AttributeExploder to get _attr_name and _attr_value attributes on the feature, and then a StringConcatenator to get the final result of _attr_name|_attr_value.
That's a good way of doing it for limited datasets. Just be aware that the AttributeExploder creates a separate feature for every attribute of every feature, so if you have 10'000 features with 60 attributes each, FME has to create 600'000 features and it will be slow.
In addition to the solution proposed by @cartoscro, here's one in Python that should have a more linear performance for larger datasets:
import fmeobjects
SEPARATOR = '|'
def processFeature(feature):
for attr in feature.getAllAttributeNames():
if not attr.startswith('fme_'):
value = feature.getAttribute(attr)
feature.setAttribute(attr, '%s%s%s' % (attr, SEPARATOR, value))
Also notice the mechanism for leaving the fme_* attributes untouched.
I would use the AttributeExploder to get _attr_name and _attr_value attributes on the feature, and then a StringConcatenator to get the final result of _attr_name|_attr_value.
This was my initial attempt, but my dataset is 30million features so I was trying to avoid exploding something that size on my laptop. Thanks though!
In addition to the solution proposed by @cartoscro, here's one in Python that should have a more linear performance for larger datasets:
import fmeobjects
SEPARATOR = '|'
def processFeature(feature):
for attr in feature.getAllAttributeNames():
if not attr.startswith('fme_'):
value = feature.getAttribute(attr)
feature.setAttribute(attr, '%s%s%s' % (attr, SEPARATOR, value))
Also notice the mechanism for leaving the fme_* attributes untouched.
This looks like the best option given my dataset dimensions, I will give it a go. Thanks!
This looks like the best option given my dataset dimensions, I will give it a go. Thanks!
You're welcome. I'd be cool to know how it works out, seeing how much data you've got.
You're welcome. I'd be cool to know how it works out, seeing how much data you've got.
@david_r Sorry for the delay in response. This works like a charm and the data is flowing smoothly! Thanks for the advice and the code!
@david_r Sorry for the delay in response. This works like a charm and the data is flowing smoothly! Thanks for the advice and the code!
No worries. Glad to hear it helped you out.