Skip to main content
Question

Attribute name from parameter value


fikusas
Contributor
Forum|alt.badge.img+5

How to set the attribute name to published/private parameter value in FME 2019.1 ? Is it possible to do ?

Original post here:

https://knowledge.safe.com/questions/2329/renaming-an-attribute-name-to-a-parameter-value.html

22 replies

takashi
Influencer
  • November 13, 2019

Hi @fikusas, you have achieved that already with the setting shown in your screenshot.

Just be aware FME Workbench cannot automatically expose the attribute name created with such a way. You can see the attribute in the Log if you connect a Logger to the AttributeCreator and run the workspace.


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 13, 2019
takashi wrote:

Hi @fikusas, you have achieved that already with the setting shown in your screenshot.

Just be aware FME Workbench cannot automatically expose the attribute name created with such a way. You can see the attribute in the Log if you connect a Logger to the AttributeCreator and run the workspace.

How can I expose this attribute then? It doesn't work in my example below, 'cause it's showing parameter name, not parameter value.


takashi
Influencer
  • November 13, 2019
takashi wrote:

Hi @fikusas, you have achieved that already with the setting shown in your screenshot.

Just be aware FME Workbench cannot automatically expose the attribute name created with such a way. You can see the attribute in the Log if you connect a Logger to the AttributeCreator and run the workspace.

FME Workbench can only expose attribute names statically determined when creating the workspace. Since a parameter value or an attribute value will be determined at run-time, FME Workbench cannot expose attribute names that will be derived from their values , unfortunately.


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 13, 2019
takashi wrote:

FME Workbench can only expose attribute names statically determined when creating the workspace. Since a parameter value or an attribute value will be determined at run-time, FME Workbench cannot expose attribute names that will be derived from their values , unfortunately.

Maybe it can be done via Python script? Unfortunately, I'm an absolute novice in Python...


david_r
Evangelist
  • November 13, 2019

takashi
Influencer
  • November 13, 2019
takashi wrote:

FME Workbench can only expose attribute names statically determined when creating the workspace. Since a parameter value or an attribute value will be determined at run-time, FME Workbench cannot expose attribute names that will be derived from their values , unfortunately.

No, there is no way to automatically expose attribute names that could be changed at run-time even if you use Python script, at least in the current version of FME Desktop.

Why do you need to expose the new attribute name given as a parameter value? Depending on the purpose, there could be a workaround without exposing the name.


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 13, 2019
takashi wrote:

No, there is no way to automatically expose attribute names that could be changed at run-time even if you use Python script, at least in the current version of FME Desktop.

Why do you need to expose the new attribute name given as a parameter value? Depending on the purpose, there could be a workaround without exposing the name.

I need to re-run the model on monthly basis and the attribute name must differ every month. For example, in November it should be named "Example201911", in December – "Example201912" and so on.


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • November 13, 2019
fikusas wrote:

I need to re-run the model on monthly basis and the attribute name must differ every month. For example, in November it should be named "Example201911", in December – "Example201912" and so on.

What is the final output for this data? It is possible to write out the attribute dynamically without it being exposed in the workspace

fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 13, 2019
ebygomm wrote:
What is the final output for this data? It is possible to write out the attribute dynamically without it being exposed in the workspace

No, it's not possible to write output dinamically, 'cause the final structure is determined in the workspace itself.


takashi
Influencer
  • November 13, 2019
takashi wrote:

No, there is no way to automatically expose attribute names that could be changed at run-time even if you use Python script, at least in the current version of FME Desktop.

Why do you need to expose the new attribute name given as a parameter value? Depending on the purpose, there could be a workaround without exposing the name.

Well, then why you need to expose the attribute name? That's the point of my question.


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 13, 2019
takashi wrote:

Well, then why you need to expose the attribute name? That's the point of my question.

I thought what FME can take attribute name from parameter, but doesn't expose it. But if it can't take name from paramater, exposing isn't helping either.


takashi
Influencer
  • November 13, 2019
takashi wrote:

Well, then why you need to expose the attribute name? That's the point of my question.

FME can take attribute name from a parameter at run-time. Exposing attribute names is not always essential. Depending on how you intend to use the attribute in the workspace, you could configure the workspace appropriately even if the attribute name wasn't exposed. I therefore would like to know why you think it's need to expose the attribute name.


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 13, 2019
takashi wrote:

FME can take attribute name from a parameter at run-time. Exposing attribute names is not always essential. Depending on how you intend to use the attribute in the workspace, you could configure the workspace appropriately even if the attribute name wasn't exposed. I therefore would like to know why you think it's need to expose the attribute name.

As I wrote earlier:

I need to re-run the model on monthly basis and the attribute name must differ every month. For example, in November it should be named "Example201911", in December – "Example201912" and so on.

This attribute is created via AttributeCreator. So it's name must be typed manually every month. I thought it can be done via fetching attribute name from parameter value, but in practise it doesn't work.


takashi
Influencer
  • November 14, 2019

As you can see in this screenshot, the attribute with your desired name can be definitely created.

Then, how do you need to use the attribute in the subsequent process? Depending on how you intend to use it, exposing its name might not be essential.


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 14, 2019
takashi wrote:

As you can see in this screenshot, the attribute with your desired name can be definitely created.

Then, how do you need to use the attribute in the subsequent process? Depending on how you intend to use it, exposing its name might not be essential.

I need to pass other attribute values to this one.


takashi
Influencer
  • November 14, 2019
takashi wrote:

As you can see in this screenshot, the attribute with your desired name can be definitely created.

Then, how do you need to use the attribute in the subsequent process? Depending on how you intend to use it, exposing its name might not be essential.

You can do this. And then?


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 15, 2019
takashi wrote:

You can do this. And then?

And then it doesn't work. Attribute name becomes "attributeNR1", not the actual value of the parameter NAME (in this case "Example201911").


david_r
Evangelist
  • November 15, 2019
fikusas wrote:

And then it doesn't work. Attribute name becomes "attributeNR1", not the actual value of the parameter NAME (in this case "Example201911").

You cannot use the visual preview table in FME for dynamic attributes, as the preview shows the static schema based on your workspace design, not the dynamic schema.

There are two options:

  1. Either send the output to the Logger and look there (as @takashi already demonstrated)
  2. In the inspector, click on the feature and use the Feature Information pane rather than the table preview. The Feature Information pane shows dynamic attributes:

As you can see, the result is an attribute called "Example201911" with the value "<strong>some value</strong>"


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 15, 2019
david_r wrote:

You cannot use the visual preview table in FME for dynamic attributes, as the preview shows the static schema based on your workspace design, not the dynamic schema.

There are two options:

  1. Either send the output to the Logger and look there (as @takashi already demonstrated)
  2. In the inspector, click on the feature and use the Feature Information pane rather than the table preview. The Feature Information pane shows dynamic attributes:

As you can see, the result is an attribute called "Example201911" with the value "<strong>some value</strong>"

But I need to write feature class to GDB with correctly named attribute. How can I do it?

david_r
Evangelist
  • November 15, 2019
fikusas wrote:
But I need to write feature class to GDB with correctly named attribute. How can I do it?

You need to use a dynamic writer with a user-defined schema feature, it's described in a fair amount of detail here: https://knowledge.safe.com/articles/1051/index.html

Welcome to the not-always-wonderful world of dynamic schemas...


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 15, 2019
david_r wrote:

You need to use a dynamic writer with a user-defined schema feature, it's described in a fair amount of detail here: https://knowledge.safe.com/articles/1051/index.html

Welcome to the not-always-wonderful world of dynamic schemas...

Hmm, it's not as simple solution that I expected, but need to look up on how to set up those dynamic schemas. Thanks!


david_r
Evangelist
  • November 15, 2019
fikusas wrote:

Hmm, it's not as simple solution that I expected, but need to look up on how to set up those dynamic schemas. Thanks!

Here's a couple of tips to make it easier for you:

  1. First use an AttributeKeeper to make sure you only have the attributes you want written
  2. Insert the SchemaSetter (from the FME Hub), it will create the necessary schema list for you and save you a lot of work
  3. Send it to a writer configured for dynamic schema, e.g. (I've highlighted the settings you have to pay particular attention to)


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