Skip to main content
Solved

negative list index in AttributeCreator

  • August 9, 2017
  • 4 replies
  • 35 views

nielsgerrits
VIP
Forum|alt.badge.img+62

Is it possible to use a negative list index in the AttributeCreator? If not possible, why not? Any technical reason or just not implemented? Should I create an Idea for it?

Workaround is to use the ListIndexer, and AttributeRenamer but this is not really intuitive nor quick. Unlike most things in FME.

Best answer by trentatsafe

Hello @nielsgerrits,

 

This negative list element is currently not implemented into FME. However, there is an idea that has been posted. If you want to head over and post a comment/upvote that will give it more standing with developers when they go to add new features.

The idea can be found here: https://knowledge.safe.com/idea/37432/reverse-list-element-selection.html

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

trentatsafe
Safer
Forum|alt.badge.img+6
  • Safer
  • Best Answer
  • August 9, 2017

Hello @nielsgerrits,

 

This negative list element is currently not implemented into FME. However, there is an idea that has been posted. If you want to head over and post a comment/upvote that will give it more standing with developers when they go to add new features.

The idea can be found here: https://knowledge.safe.com/idea/37432/reverse-list-element-selection.html


jneujens
Forum|alt.badge.img
  • August 9, 2017

import fme
import fmeobjects

def processFeature(feature):
    list = feature.getAttribute('_testList{}.testattribute')
    print list[-1]
 

In those cases, I think it is easy to work with a pythoncaller.

I have added a small sample workspace that builds a simple list attribute. The pythoncaller is used to extract this list attribute into a new python list variable (see code above). There it is possible to use negative indices.

This is just a simple example to show you this is possible. ;) 


nielsgerrits
VIP
Forum|alt.badge.img+62

Hello @nielsgerrits,

 

This negative list element is currently not implemented into FME. However, there is an idea that has been posted. If you want to head over and post a comment/upvote that will give it more standing with developers when they go to add new features.

The idea can be found here: https://knowledge.safe.com/idea/37432/reverse-list-element-selection.html

Heya @trentatsafe,

 

Thanks for pointing out, I should have searched the Ideas as well before posting this question.

 


nielsgerrits
VIP
Forum|alt.badge.img+62

import fme
import fmeobjects

def processFeature(feature):
    list = feature.getAttribute('_testList{}.testattribute')
    print list[-1]
 

In those cases, I think it is easy to work with a pythoncaller.

I have added a small sample workspace that builds a simple list attribute. The pythoncaller is used to extract this list attribute into a new python list variable (see code above). There it is possible to use negative indices.

This is just a simple example to show you this is possible. ;) 

Heya @jneujens,

 

Thanks for the working example!