Skip to main content
Solved

I am trying to find a way to essentially extract characters in a list until the end of that list

  • January 31, 2020
  • 4 replies
  • 24 views

chrbalm
Contributor
Forum|alt.badge.img+8

I want to find a way to pull out the first 13 characters in each list element until the list ends (identified by ItemsInList attribute). I currently have this:

@Left(@Value(_list_UAIDs{@Value(ItemsInList)}),13)

However this only returns the last entry. I want it to return every instance within the list.

I wasn't sure if it was that simple of if I could create a looper to resolve this?

Best answer by oscard

Would it be possible for your data to explode the list with the ListExploder, use the function you have posted and then build the list again?

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.

4 replies

oscard
Influencer
Forum|alt.badge.img+22
  • Influencer
  • 344 replies
  • Best Answer
  • January 31, 2020

Would it be possible for your data to explode the list with the ListExploder, use the function you have posted and then build the list again?


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • January 31, 2020

If not wanting to explode the list, I'd probably use python to do this.


chrbalm
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • 15 replies
  • January 31, 2020

Exploding for this purpose has done the trick, but I still would find it interesting if it's possible to extract this data in a single cell, maybe separated by a comma?


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • January 31, 2020

Exploding for this purpose has done the trick, but I still would find it interesting if it's possible to extract this data in a single cell, maybe separated by a comma?

If you wanted to use a pythoncaller, this would create a new comma separated value in an attribute called first_13 where _list{}.value is the name of your list

import fme
import fmeobjects

def firstthirteen(feature):

    mylist = [value[:13] for value in feature.getAttribute('_list{}.value')]  
    feature.setAttribute("first_13",','.join(mylist))