Skip to main content
Question

Schemamapper - multiple attributes to one


sigtill
Contributor
Forum|alt.badge.img+24
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

sigtill
Contributor
Forum|alt.badge.img+24
  • Author
  • Contributor
  • October 3, 2013
Also tried:

 

@Value(FirstName)@Value(LastName),FullName

jelle
Contributor
Forum|alt.badge.img+16
  • Contributor
  • October 3, 2013
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

sigtill
Contributor
Forum|alt.badge.img+24
  • Author
  • Contributor
  • October 3, 2013
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)

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • October 3, 2013
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

sigtill
Contributor
Forum|alt.badge.img+24
  • Author
  • Contributor
  • October 3, 2013
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:)).

 

 

 


sigtill
Contributor
Forum|alt.badge.img+24
  • Author
  • Contributor
  • October 3, 2013
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

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • October 3, 2013
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.

sigtill
Contributor
Forum|alt.badge.img+24
  • Author
  • Contributor
  • October 3, 2013
Ah,great - now it works with both options! Just had to put the formula in "DEFAULTVALUE" - column and not InputAttribute. Thank you

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • October 4, 2013
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.

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • October 4, 2013
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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings