Skip to main content
Solved

Merging features into a single textline

  • November 28, 2018
  • 6 replies
  • 455 views

Forum|alt.badge.img

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.

Best answer by takashi

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

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.

6 replies

redgeographics
Celebrity
Forum|alt.badge.img+60
  • Celebrity
  • 3702 replies
  • November 28, 2018

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.


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3429 replies
  • November 28, 2018

Take a look at the aggregator

single_textline.fmwt


takashi
Celebrity
  • 7843 replies
  • Best Answer
  • November 29, 2018

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


Forum|alt.badge.img
  • Author
  • 26 replies
  • November 29, 2018

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.

Forum|alt.badge.img
  • Author
  • 26 replies
  • November 29, 2018

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


Forum|alt.badge.img
  • Author
  • 26 replies
  • November 29, 2018

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