Skip to main content
Hi All,

 

  1. I have designed a workbench in which i will pass an input field to StringLengthCalculator transformer and the result is stored in a default attribute (_length).
  2. Then, i have passed this (_length attribute) to ExpressionEvaluator  transformer to calculate values based on this formula                                (13 - @value(_length))+ @value(_length) and the resultant value is stored in default attribute (_result)
  3. This _result attribute is mapped to pad width parameter of StringPadder transformer and a particular field is selected in it which needs to be updated in target.
  4. I can see the trailing spaces on the target field to the left.

 

But, my main challenge is how to perform this flow on all fields because we cannot give uniform pad width to all fields and pad width shoulddepend on the stringlength of different field values in source table and all the target fields should have different number of trailing spaces based on their source string value.

 

 

Kindly provide me some idea ? :)

 

Hi.

 

 

Maybr the following my help

 

http://fmestore.safe.com/transformers/StringLengthFormatter.htm
Thanks Itay. String Formatters works!
Hi Seeni,

 

 

If many different fields should be treated simultaneously, I would use the PythonCaller with a script like:

 

---

 

import fmeobjects   # Target field names TARGETS = set( 'attr1', 'attr2', 'attr3'])   def paddingLeft(feature):     for name in feature.getAllAttributeNames():         if name in TARGETS:             s = str(feature.getAttribute(name))             # Calculate padding size. Modify appropriately.             n = 13 - len(s)             if 0 < n: feature.setAttribute(name, (n * ' ' + s)) ---

 

Takashi

Reply