Skip to main content
Question

Hi. I am using FME workbench 2022.2, made a custom transformer and want to automate to run multi times in a script depending on the number of differences in valeu of an attribute (this may varies).


louis_boekhoudt
Contributor
Forum|alt.badge.img+2

I plan to use this method after a transformer "AttributeFilter".

So the the number of cases the valeu of an ttribute varies define the repetition number the transformer .

 

11 replies

hkingsbury
Celebrity
Forum|alt.badge.img+54
  • Celebrity
  • March 6, 2023

I'm gathering you're essentially wanting find all unique values in a dataset and pass each unique value into the transformer?

 

You could either use the duplicate filter or sampler (with groupby set to the attribute name and "first n features" selected.

 

Both of these approaches will give you one feature for each different value in the select attribute


louisboekhoudt
Contributor
Forum|alt.badge.img+1
hkingsbury wrote:

I'm gathering you're essentially wanting find all unique values in a dataset and pass each unique value into the transformer?

 

You could either use the duplicate filter or sampler (with groupby set to the attribute name and "first n features" selected.

 

Both of these approaches will give you one feature for each different value in the select attribute

Yes excacly.


louisboekhoudt
Contributor
Forum|alt.badge.img+1
hkingsbury wrote:

I'm gathering you're essentially wanting find all unique values in a dataset and pass each unique value into the transformer?

 

You could either use the duplicate filter or sampler (with groupby set to the attribute name and "first n features" selected.

 

Both of these approaches will give you one feature for each different value in the select attribute

Thanks for the hint. Will try your sugestion.


louisboekhoudt
Contributor
Forum|alt.badge.img+1

Hi hkingsbury,

From an xlsx file with thousand records I need to filter by one attribute, in this case the "ID-CODE".

Using transformer "ATTRIBUTE FILTER" I can redirect each record to a deferent outport, depending on the "ID-CODE" attribute valeu. The costum transfomer must proces all the records passing through each outport separatly.

So the records passing through the 1st outport has to be processed by the costum transformer, then the records passing through the 2nd outport and so on till all the outports are processed without using copy and paste. The costum transformer has to be recalled for each outport.

Hope I could make the case clearer.

 


louisboekhoudt
Contributor
Forum|alt.badge.img+1

Hi here a screenshot of the script using copy and paste.


louisboekhoudt
Contributor
Forum|alt.badge.img+1

Screenshot of the script.


geomancer
Evangelist
Forum|alt.badge.img+48
  • Evangelist
  • March 7, 2023

Out of curiosity: why do you need to use a different instance of your custom transformer for each "ID-CODE"? Although I don't know the contents of your custom transformer, it looks like this may not be necessary.


louis_boekhoudt
Contributor
Forum|alt.badge.img+2
geomancer wrote:

Out of curiosity: why do you need to use a different instance of your custom transformer for each "ID-CODE"? Although I don't know the contents of your custom transformer, it looks like this may not be necessary.

Hi geomancer, thanks for replying.

As you noticed each record has an unique "ID-CODE". Each records has many more attributes which I will aggregate together for further use (relate 1 to 1).

The aggregation has to be performed for each 'ID-CODE" resulting in 1 record for each. By using the custom transformer once all the records will be aggregated in one record. Hope I could make it clearer.


geomancer
Evangelist
Forum|alt.badge.img+48
  • Evangelist
  • March 8, 2023
geomancer wrote:

Out of curiosity: why do you need to use a different instance of your custom transformer for each "ID-CODE"? Although I don't know the contents of your custom transformer, it looks like this may not be necessary.

I still expect you don't need a custom transformer.

If every "ID-CODE" exists only once, you can just process every record individually (FME does this by default).

In the case an "ID-CODE" exists serveral times, and you want to aggregrate all records with the same "ID-CODE", you can usually use a ListBuilder, setting 'Group By' to "ID-CODE", create a list of the attributes of the original records with the same "ID-CODE", and perform the aggregation on the attributes in the list.

This will also make your workspace more versatile and more robust, as you can process future data sets without having to set all unique values for "ID-CODE" explicitly in your workspace.


louis_boekhoudt
Contributor
Forum|alt.badge.img+2

Hi geomancer, thanks again for replying.

 

Your last reply was very helpfull. I put in use a "ListBuilder" as you sugested with Group By set to "ID-CODE" and could work out the script wich is now performing perfectly. Many thanks for the hint. I was overlooking the "ListBuilder" capabilities.


geomancer
Evangelist
Forum|alt.badge.img+48
  • Evangelist
  • March 10, 2023

You're welcome :)


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