Skip to main content
Question

Schemamapper - multiple attributes to one

  • Oct 3, 2013 8:23 AM UTC
  • 10 replies
  • 79 views

sigtill
Supporter
Forum|alt.badge.img+25
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 ???

 

 

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

10 replies

sigtill
Supporter
Forum|alt.badge.img+25
  • Author
  • Supporter
  • Oct 3, 2013 8:28 AM UTC
Also tried:

 

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

jelle
Contributor
Forum|alt.badge.img+23
  • Contributor
  • Oct 3, 2013 9:50 AM UTC
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
Supporter
Forum|alt.badge.img+25
  • Author
  • Supporter
  • Oct 3, 2013 10:30 AM UTC
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
Celebrity
  • Oct 3, 2013 10:54 AM UTC
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
Supporter
Forum|alt.badge.img+25
  • Author
  • Supporter
  • Oct 3, 2013 11:22 AM UTC
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
Supporter
Forum|alt.badge.img+25
  • Author
  • Supporter
  • Oct 3, 2013 11:26 AM UTC
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
Celebrity
  • Oct 3, 2013 12:34 PM UTC
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
Supporter
Forum|alt.badge.img+25
  • Author
  • Supporter
  • Oct 3, 2013 1:07 PM UTC
Ah,great - now it works with both options! Just had to put the formula in "DEFAULTVALUE" - column and not InputAttribute. Thank you

takashi
Celebrity
  • Oct 4, 2013 3:19 AM UTC
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
Celebrity
  • Oct 4, 2013 6:18 AM UTC
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)}])

 

-----