Skip to main content
Solved

Getting lists in PythonCaller

  • September 5, 2017
  • 7 replies
  • 867 views

Forum|alt.badge.img+1

Hi,

I am using FME Desktop 2017 and would like to know if there is a way to get a list that I have generated in my FME Workflow, into the PythonCaller, in a similar way to how you use 'getAttribute' function feature.getAttribute(x) to get a normal attribute into the PythonCaller.

Thank you for your help in advance.

Best answer by jdh

For simple and compound lists you can just use

 

 

feature.getAttribute('list{}') or feature.getAttribute('list{}.x')

 

 

For nested lists you need to loop through the parent list to get the sublists.

View original
Did this help you find an answer to your question?

7 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • September 5, 2017

For simple and compound lists you can just use

 

 

feature.getAttribute('list{}') or feature.getAttribute('list{}.x')

 

 

For nested lists you need to loop through the parent list to get the sublists.


danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • September 5, 2017

Hi @aquamarine,

I created a Workspace that show the print values from a List ( _list{}.names ) in Log file using the PythonCaller:

Thanks,

Danilo


Forum|alt.badge.img+1
  • Author
  • September 5, 2017
jdh wrote:

For simple and compound lists you can just use

 

 

feature.getAttribute('list{}') or feature.getAttribute('list{}.x')

 

 

For nested lists you need to loop through the parent list to get the sublists.

That's exactly what I needed!

 

Thank you @jdh

 


Forum|alt.badge.img
  • January 10, 2018
danilo_fme wrote:

Hi @aquamarine,

I created a Workspace that show the print values from a List ( _list{}.names ) in Log file using the PythonCaller:

Thanks,

Danilo

Hi all

 

I am getting from Excel a column called Name,

 

after I built lists with Listbuilder ,

 

but I have an error in my pythoncaller,

 

please provide some feedback

 

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 10, 2018
josesauz wrote:
Hi all

 

I am getting from Excel a column called Name,

 

after I built lists with Listbuilder ,

 

but I have an error in my pythoncaller,

 

please provide some feedback

 

 

If you inspect the features prior to the PythonCaller, does every feature have a value for _list{0}.Name?

 

 

You can try adding "if Nombres:" just prior to the for loop, so that there is no python exception if there list doesn't exist.

 

 

 


Forum|alt.badge.img
  • January 11, 2018
jdh wrote:
If you inspect the features prior to the PythonCaller, does every feature have a value for _list{0}.Name?

 

 

You can try adding "if Nombres:" just prior to the for loop, so that there is no python exception if there list doesn't exist.

 

 

 

 

Yes, the list has many values , I dont know is I can iterate the object..

 

@takashi , @david_r , @danilo_fme , @takashi

 

I am using FME 2016.1


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 11, 2018
josesauz wrote:

 

Yes, the list has many values , I dont know is I can iterate the object..

 

@takashi , @david_r , @danilo_fme , @takashi

 

I am using FME 2016.1

There seems to be some white space at the end of the _list{}.Name attribute.

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings