Skip to main content
Question

Modifying User Attribute Types in a Transformer

  • July 10, 2013
  • 6 replies
  • 1096 views

Forum|alt.badge.img
Dear community,

 

 

is there a way how I can set a data type (integer, char, float, ...) in a transformer?

 

 

Usually I create the data type in the Feature Type Properties menu of the Writer. On some occassion, it would be helpfull if I could set the types manuelly in a transformer, so that the writer recognizes the formats automatically.

 

 

I do not want to tell every writer which format it has to be. We can of course tell a single writer all the data types and then copy the attributes from one Writer to another. This one should work.

 

 

But can I set the data type to a specific type in a transformer before I write the data out?

 

 

Thank you very much for your help.

 

 

Kind regards,

 

ThomasK

 

 

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.

6 replies

david_r
Celebrity
  • 8392 replies
  • July 10, 2013
Hi,

 

 

this is not really possible (without dirty hacks, see my Python code here) due to the way FME works internally.

 

 

Also, to me it seems a bit dubious to assume that the first feature that enters the writer can properly describe all the following features. E.g. what happens if the first feature contains an integer for attribute A, whereas the next feature contains a string in attribute A?

 

 

My opinion is that explicit is better than implicit, so I'd recommend configuring the writer with set datatypes rather than relying on the first feature to define the schema.

 

 

David

Forum|alt.badge.img
  • Author
  • 71 replies
  • July 10, 2013
Hi David,

 

 

thank you very much for your response.

 

 

The writer should not recognize the data types by the first feature that enters it, but by the definitions made by the user in a (possible not existing) transformer before the writer. A colleague of mine wants to define these data types in a transformer (or preferably directly in the PythoCaller, but I guess that's not possible, is it?), rather than to do it in the writers menu.

 

 

I once's read an article about how the data types are stored in the FME but could't find it anymore. I guess it was in the FMEpedia. If someone has information about it, it would also be helpful.

 

 

Kind regards

 

ThomasK

takashi
Celebrity
  • 7843 replies
  • July 10, 2013
Hi Thomas,

 

 

> how the data types are stored in the FME

 

 

This documentation is describing that "FME stores all attributes as character strings ...".

 

 

Takashi

helmoet
Forum|alt.badge.img+8
  • 195 replies
  • October 10, 2017
Hi @thomask, I have the same need, since I read dgnV8 which delivers texts string(200) and want to write them to spatialLite database, which I configured to write string(20). However, it refuses to do so and writes instead string(200). Trying to find an answer...

helmoet
Forum|alt.badge.img+8
  • 195 replies
  • October 10, 2017

On the other hand, it seems you're looking for a dynamic setup using advanced schema contructing. Here is good starting documentation: https://knowledge.safe.com/articles/43899/dynamic-workflows-advanced-example-modifying-the-s.html and https://s3.amazonaws.com/gitbook/Desktop-Advanced-2016/DesktopAdvanced4AdvancedRW/4.15.AdvancedDynamicSchemas.html

You will have to use a dynamic feature type on the reader, and "Schema from first Feature" as schemasource. Using for example an AttributeCreator you can define your attribute types in the attribute{}.fme_data_type and attribute{}.name array and write them to the dynamic writer, which write the correct data types.

That wouldn't fix my problem, however, that seems to be fixed in fme 2017.


bleutzinn
  • 2 replies
  • May 26, 2020

Desparately looking for an answer I discovered the solution was right under my nose: simply use an AttributeManager as the first transformer from a Reader.

 

With action set to "Set value" in the "Attribute Value" field you can use the Math functions to set the desired data type. For example:

@double(@Value(temperature)) 

You can even change the data type and rename an attribute at the same time by setting action to "Rename" and then use the new attribute name in the "Attribute Value" field.