Solved

Merging features into a single textline

  • 28 November 2018
  • 6 replies
  • 53 views

Badge

Hi I have lots of features that have a datetime and some attributes, I need to group all the ones that happen in the same day on a single line. I need attributes A, B, C from the earliest item that day then I need to add attributes B and C from the other occurrences that day to the same text line.

I have split the date time up so I can see the year day month and time as separate attributes if needed.

If I have 4 attributes in a day then I would want them all grouped up into the same output text line exept the type needs tom come from the attribute with the earliest time

 

type(A) datetime(B) height(C)

90 2001-01-01T02:24:00 10

91 2001-01-01T08:28:00 15

90 2001-01-01T12:40:00 9

91 2001-01-01T23:24:00 14

90 2001-02-01T02:24:00 8

91 2001-02-01T08:28:00 16

90 2001-02-01T12:40:00 9

91 2001-02-01T23:24:00 12

 

so for the data above the 2 strings I'm trying to create would be

90 2001-01-01T02:24:00 10 2001-01-01T08:28:00 15 2001-01-01T12:40:00 9 2001-01-01T23:24:00 14

90 2001-02-01T02:24:00 8 2001-02-01T08:28:00 16 2001-02-01T12:40:00 9 2001-02-01T23:24:00 12

 

I think the feature merger might work but Im unsure how to split them into requestors and suppliers, the earliest item from each day needs to be the requestor and the rest the suppliers.

I'm sure I'm missing something obvious as this doesn't seeem too tricky, any help much appreciated.

Hoping there is a transformer way of doing this before I fall back to writing something in python.

icon

Best answer by takashi 29 November 2018, 04:28

View original

6 replies

Userlevel 5
Badge +25

I'm converting the datetime to an FME Date (e.g. 20010101), then sample based on those values, first occurence gets split off, all the others get a list built out of them. Concatenate the datetime and heights in that list into a new attribute, Featuremerge back to the first one and that's it.

csv22none.fmwt

Hope this helps.

Userlevel 1
Badge +21

Take a look at the aggregator

single_textline.fmwt

Userlevel 2
Badge +17

Alternatively, the Attributes to Concatenate option parameter in the Aggregator could also be used effectively.

Badge

Alternatively, the Attributes to Concatenate option parameter in the Aggregator could also be used effectively.

thanks Takashi, I went for this answer in the end as combining the time height and concatonating in the aggregator made things a bit simpler when generating my final output string.
Badge

Take a look at the aggregator

single_textline.fmwt

Aggregator! thats the thing I was missing, I knew there was something I had used before, great answer thanks, but went with Takashi's one in the end, seemed the most elegant

Badge

I'm converting the datetime to an FME Date (e.g. 20010101), then sample based on those values, first occurence gets split off, all the others get a list built out of them. Concatenate the datetime and heights in that list into a new attribute, Featuremerge back to the first one and that's it.

csv22none.fmwt

Hope this helps.

thanks for the answer, I didnt use this method in the end but it was helpful, I havent used the sampler before, didnt know it existed but I have now made use of it now elswhere in the project thanks to you highlighting it

Reply