Skip to main content

Hello FME community,

 

I have loaded a text file as CSV into the workflow so that a table is created.

This then looks like this:FME_Table_QuestionI need a process that can work independently of the number of attributes but according to a pattern.

 

Therefore I have converted these attributes into a list.

 

Here is an excerpt from it: (fme_basename: 102)

_list{0}.col2   892

_list{0}.col3   1448

_list{0}.col4   48

_list{0}.col5   70

_list{0}.col6   874

_list{0}.col7   1628

_list{0}.col8   50

_list{0}.col9   78

 

The pattern looks like this:

col2 and col6 belong in one attribute (x)

col3 and col7 belong in one attribute (y)

col4 and col8 belong in one attribute (dx)

col5 and col9 belong in one attribute (dy)

 

So every 4th element belongs to the same attribute.

I would like to change the list so that the index can be set according to the pattern.

 

This would then have to look like this:

_list{0}.col2   892

_list{1}.col3   1448

_list{2}.col4   48

_list{3}.col5   70

_list{0}.col6   874

_list{1}.col7   1628

_list{2}.col8   50

_list{3}.col9   78

 

Then I would have the possibility, based on the index, to write the elements into the respective attributes.

Do you guys have any ideas on how to make this happen?

 

I am not proficient in the programming language. Otherwise this would probably be a piece of cake.

 

Best regards

Thanks for your question @diroxas​ ! One solution with FME would be to use a single transformer called the AttributeManager to expose your list items, create attributes combining the list values, as well as having renamed these new attributes to x, y, dx, and dy.

 

For more information on the AttributeManager check out this article!


Thanks for your question @diroxas​ ! One solution with FME would be to use a single transformer called the AttributeManager to expose your list items, create attributes combining the list values, as well as having renamed these new attributes to x, y, dx, and dy.

 

For more information on the AttributeManager check out this article!

Hello @Evie Lapalme​ 

The AttributeManager is also used at the end to convert the list back into attributes.

 

But before that I have to adjust the list according to the index. Because the workflow has to remain dynamic due to different amounts of input data (sometimes it is only 4 or sometimes more than 200), I decided to use the list processing. The advantage of this is that the pattern always remains the same. Regardless of the number of inputs.

I would like to take advantage of this circumstance.


Hello @Evie Lapalme​ 

The AttributeManager is also used at the end to convert the list back into attributes.

 

But before that I have to adjust the list according to the index. Because the workflow has to remain dynamic due to different amounts of input data (sometimes it is only 4 or sometimes more than 200), I decided to use the list processing. The advantage of this is that the pattern always remains the same. Regardless of the number of inputs.

I would like to take advantage of this circumstance.

Can you give an example of what you are hoping the final output to be?


I'm not quite sure about the final output you hope to achieve. In this simple example, I concatenate columns with a separator character, and next remove the superfluous separator characters from the end of the string.

It would be somewhat cumbersome to enter all those column names, when you have over 200 of them, but you have to create the definitions in the AttributeCreator only once.

Concat 


Hello @Evie Lapalme​ 

The AttributeManager is also used at the end to convert the list back into attributes.

 

But before that I have to adjust the list according to the index. Because the workflow has to remain dynamic due to different amounts of input data (sometimes it is only 4 or sometimes more than 200), I decided to use the list processing. The advantage of this is that the pattern always remains the same. Regardless of the number of inputs.

I would like to take advantage of this circumstance.

Hey, @ebygomm​ and @geomancer​ 

I apologize for the late reply.

 

I have manually created an example of what it should look like in the end:

FME_Table_Exit 

I thought that dynamic editing using lists would be the best way to do this


Hello @Evie Lapalme​ 

The AttributeManager is also used at the end to convert the list back into attributes.

 

But before that I have to adjust the list according to the index. Because the workflow has to remain dynamic due to different amounts of input data (sometimes it is only 4 or sometimes more than 200), I decided to use the list processing. The advantage of this is that the pattern always remains the same. Regardless of the number of inputs.

I would like to take advantage of this circumstance.

A solution with only standard transformers, continuing on my previous idea.

  • Concatenate all 'col' attributes, using a separator character (_ in this example). But use another separator character every 4th time (# in this example), like
@Value(col2)_@Value(col3)_@Value(col4)_@Value(col5)#@Value(col6)_@Value(col7)_@Value(col8)_@Value(col9)#@Value(col10)_@Value(col11)_@Value(col12)_@Value(col13)
  • Drop superflouous #___
  • Split on #, use a ListExploder to create extra features.
  • Next split on _, and again use a ListExploder to create extra features. 
  • Filter on the Element Index Attribute, create one of the attributes X, Y , DX, DY in each branch.
  • Merge the appropriate features, and do some cleanup.

Concat_2 


Reply