Skip to main content
Question

Dynamic Attribute creation

  • July 9, 2020
  • 11 replies
  • 479 views

Forum|alt.badge.img

I have a json which i am getting through http caller.

This json contains data as well as schema details.

The schema details are like this

Column Name, ColumnIdentifier

 

and Data is like this [{ColoumnIdentifier : Value}]

 

Now i want to create new attributes based on schema details.

I have looked into python caller but i think you cannot create new attributes.

 

is there any transformer by which i can create new attributes using my json as an input?

or a python function to create new attributes

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.

11 replies

redgeographics
Celebrity
Forum|alt.badge.img+61
The JSONFlattener and/or JSONFragmenter should do the trick, although if you want to work with those attributes in other FME transformers you'll need to expose them (and in order to do that you'll need to know what they're called)

Forum|alt.badge.img
  • Author
  • July 9, 2020
The JSONFlattener and/or JSONFragmenter should do the trick, although if you want to work with those attributes in other FME transformers you'll need to expose them (and in order to do that you'll need to know what they're called)

Thats the thing. It is dynamic. I cannot hardcode name of columns. This is why i am looking for a way to create new attributes based on that JSON.

I am using JSON Fragmenter and i am showing them in inspector but how can i create new attributes


ebygomm
Influencer
Forum|alt.badge.img+45
  • Influencer
  • July 9, 2020

Thats the thing. It is dynamic. I cannot hardcode name of columns. This is why i am looking for a way to create new attributes based on that JSON.

I am using JSON Fragmenter and i am showing them in inspector but how can i create new attributes

What is the end result? If you are writing out to another file, it is not necessary to expose the attributes. If you need to expose the attributes on the canvas, your workspace is no longer dynamic


Forum|alt.badge.img
  • Author
  • July 9, 2020

What is the end result? If you are writing out to another file, it is not necessary to expose the attributes. If you need to expose the attributes on the canvas, your workspace is no longer dynamic

Very good point indeed.

 

Yes as an end result i am writing a feature class.

Forum|alt.badge.img
  • Author
  • July 9, 2020

Very good point indeed.

 

Yes as an end result i am writing a feature class.

But still there is not way to create new attributes ?

 

from some list or json

ebygomm
Influencer
Forum|alt.badge.img+45
  • Influencer
  • July 9, 2020

If you want to create new attributes from values this can be done in an attributecreator, so you use the value in a one column to create the attribute name and the value in another to set the value, e.g.

The attributes will be created and can be seen in the feature information window and can be written out dynamically but will not be available on the canvas

 

You can use a pythoncaller to do the same


Forum|alt.badge.img
  • Author
  • July 12, 2020

If you want to create new attributes from values this can be done in an attributecreator, so you use the value in a one column to create the attribute name and the value in another to set the value, e.g.

The attributes will be created and can be seen in the feature information window and can be written out dynamically but will not be available on the canvas

 

You can use a pythoncaller to do the same

Hi

Thank you i am trying this approach and i tried exporting it to csv file for a test.

Still do not works. Is there something which i am missing ?


virtualcitymatt
Celebrity
Forum|alt.badge.img+47

Hi

Thank you i am trying this approach and i tried exporting it to csv file for a test.

Still do not works. Is there something which i am missing ?

You will need to create a schema feature. You can give the SchemaSetter a go. It will add a list list in the structure which FME can use to define the schema on output. The transformer will add a list to each feature but you only need one feature. The feature with the schema list must be the first to get to the writer.

There are two special attributes you can set on the SchemaFeature which will help:

"fme_schema_handling"

And

"fme_feature_type_name"

You should double check the attribute names (I just wrote from memory)

set fme_schema_handling to: schema_only

and the fme_feature_type_name should the output feature type which all the rest of the features need to have set.

Here is a bit of a tutorial with some actual examples:

https://knowledge.safe.com/articles/1051/dynamic-workflow-tutorial-destination-schema-is-de-2.html


Forum|alt.badge.img

If you want to create new attributes from values this can be done in an attributecreator, so you use the value in a one column to create the attribute name and the value in another to set the value, e.g.

The attributes will be created and can be seen in the feature information window and can be written out dynamically but will not be available on the canvas

 

You can use a pythoncaller to do the same

@ebygomm​ It works perfectly fine the way you describe it. But what is the point to create a non exposed attribute. One would work with its content, won't I?


ebygomm
Influencer
Forum|alt.badge.img+45
  • Influencer
  • August 30, 2023

@ebygomm​ It works perfectly fine the way you describe it. But what is the point to create a non exposed attribute. One would work with its content, won't I?

You can write out unexposed attributes dynamically, so there are use cases where you would want to create an attribute and write that to a file, without any requirement to work with the content of those unexposed attributes.


australgis
Contributor
Forum|alt.badge.img+3
  • Contributor
  • April 30, 2025

Just reading this post, there is still no way to name an attribute using a value and making visible in the canvas?