Skip to main content
Hi I need to end up with a column that looks like this

 

 

SDRC00001

 

SDRC00002

 

.....etc

 

the sequential numbers at the end of the string come from another column.

 

 

What transformer do I use for the leading zeros and how do I do it?

 

 

cheers,
Use the Stringformatter on the last part ( 00001) with parameters 05s (creates a string with 5 integers putting zeros to the LEFT) 

 

 

Then use an AttributeCreator to merge the number (00001) with the text-attribute (SDRC)
Hi,

 

 

just as an alternative to the StringFormatter, you can also use the StringPadder. I sometimes find the results a bit more predictable.

 

 

David
Hi,

 

 

And also, PadLeft function from FME String Functions can be used in the AttributeCreator or the StringConcatenator. @Value(Prefix)@PadLeft(@Value(Number),5,0)

 

 

Here is a miserable cat to be skinned 🙂

 

Takashi
Well, since we're going down that path, here's a solution for a PythonCaller :-)

 

 

def FeatureProcessor(feature):     attrib_to_trim = "MY_ATTRIBUTE"     pad_width = 10     pad_char = "0"     feature.setAttribute(attrib_to_trim,          str(feature.getAttribute(attrib_to_trim)).         rjust(pad_width, pad_char))

 

David
Haha, very good example of the fact that you can do the same thing 100 different ways with FME 🙂
It's a great thing of FME that there are various approaches to do the same thing. Also enjoy a TclCaller. format {%s%05s} [FME_GetAttribute "Prefix"] [FME_GetAttribute "Number"]
poor cat ... 😉

Reply