Skip to main content
Solved

Setting a list of lists as a _list attribute in PythonCaller?


fneal
Contributor
Forum|alt.badge.img+4
  • Contributor

I have a list of lists resembling this structure:

sublists = [[1,2,3],[4,5,6],[7,8,9]]

 

When I try to set this "list of lists" into a list attribute I get the following:

code -

feature.setAttribute('chunkList{}', sublists)

 

error -

Python Exception <TypeError>: Could not convert attribute value to a supported attribute type.

Traceback (most recent call last):

 File "<string>", line 95, in input

TypeError: Could not convert attribute value to a supported attribute type.

Error encountered while calling method `input'

PythonCaller_Get_chunkList (PythonFactory): PythonFactory failed to process feature

 

  1. The goal is to have a list of 1000 unique IDs or less to feed into a reader
  2. I do not know how many lists there will be ahead of time so I need to dynamically break out the lists into individual lists of 1000 elements later in the workflow which is why I want 1 list of lists to start with.

 

 

 

Best answer by david_r

Try something like

sublists = [[1,2,3],[4,5,6],[7,8,9]]
for n, item in enumerate(sublists):
    feature.setAttribute('chunkList{%s}.sublist{}' % n, item)

Result:

imageYou can then do a ListExploder on chunkList, if you need to have one feature per sublist.

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

2 replies

david_r
Evangelist
  • Best Answer
  • October 30, 2023

Try something like

sublists = [[1,2,3],[4,5,6],[7,8,9]]
for n, item in enumerate(sublists):
    feature.setAttribute('chunkList{%s}.sublist{}' % n, item)

Result:

imageYou can then do a ListExploder on chunkList, if you need to have one feature per sublist.


fneal
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • October 30, 2023

Thanks for the quick response @david_r​, that did the trick! I did want each feature to have its own sub-list which I exposed and then concatenated, giving me the queries I will need for each set of records to fetch from a reader.

 

Sublists


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