Question

Schemamapper - multiple attributes to one


Badge +21
Hi!

 

 

I want to map multiple attributes to one using the Schemamapper:

 

 

Ie:

 

 

InputFeature:

 

FirstName: Roger

 

Lastname: More

 

 

OutputFeature:

 

FullName: Roger More

 

 

How should the SchemaMapper.csv look like?

 

 

FullName, FirstName + LastName ???

 

 

 

 


10 replies

Badge +21
Also tried:

 

@Value(FirstName)@Value(LastName),FullName
Badge +11
Hi, 

 

 

I always have to refer to http://fmepedia.safe.com/articles/Samples_and_Demos/Mapping-Schemas-using-SchemaMapper when using the SchemaMapper. Maybe, you can find your case in one of these examples? 

 

 

best regards, 

 

Jelle
Badge +21
Hi! Thanks for the reply - however as far as I can see none of those cases describe my case.

 

 

I want to "merge" two input-attributes (Firsname AND Lastname) to a new attribute (FullName)
Userlevel 2
Badge +17
Hi Sig,

 

 

In my testing, Tcl "concat" command worked well. @Evaluate([concat @Value(FirstName) @Value(LastName)]),FullName   I'm not familiar with Tcl, cannot describe more details... By the way, why not use the StringConcatenator or the AttributeCreator?

 

Takashi
Badge +21
Hi Takashi!

 

 

I am aware how to do it within FME - however the reason the SchemaMapper exist is to separate the mapping from FME itself (ie let a domain-expert do the mapping in EXCEL and the FME-expert take care of the rest:)).

 

 

 

Badge +21
Another option I tried was to do the following in the CSV:

 

 

InputAttribute OutputAttribute Firstname FullName @Value(FullName) @Value(LastName)' FullName

 

However that did not seem to work either - as the last value overwrote the Firstname
Userlevel 2
Badge +17
Tcl "format" command also worked fine. It might be more flexible than "concat" command. @Evaluate([format "%s %s" @Value(FirstName) @Value(LastName)])   I agree with you. There could be such a situation - dividing roles by domain-expert and FME-expert.
Badge +21
Ah,great - now it works with both options! Just had to put the formula in "DEFAULTVALUE" - column and not InputAttribute. Thank you
Userlevel 2
Badge +17
I learned Tcl a little more. This expression also worked, for what it's worth.

 

@Evaluate([return "@Value(FirstName) @Value(LastName)"])

 

 

I've never used Tcl so far, but it seems to have big availability especially for string processing.
Userlevel 2
Badge +17
P.S. These are better if FirstName or LastName may contain a special character (" [ ]  <white space> etc.).

 

-----

 

@Evaluate([return {@Value(FirstName) @Value(LastName)}]) @Evaluate([format "%s %s" {@Value(FirstName)} {@Value(LastName)}]) @Evaluate([concat {@Value(FirstName)} {@Value(LastName)}])

 

-----

Reply