Dealing with lists in Knime

Hi all,
Is there a way to manipulate list data type in Knime, e.g, I have a column with the following:
MyColumn
[100 asdas St, asdas QLD 4214, Australia]
[154 asdasSt, asdasd Island QLD 4875, Australia]
[180 adasd Rd, asdas asdasd QLD 4555, Australia]

and I want to do something like that:
MyColumn[0] which should give me the first element in my list
MyColumn[1] giving me the next.

Hope someone can direct me.
Thanks

Hi,
did you get this data from a file? If yes, why do you do not use e.g. CSV READER node there you can define the Column Delimiter “,”. Then you get the Information automatically in columns. Otherwise you can try the CELL SPLITTER node.

BR
Hermann

I got it as part of a json output from google api get request, i was more so interested in finding out whether there were list, dictionary functions available

You could use the Expand Collection Column node, and pick the element that you want with a Column Filter, but it seems that that is not what you want.

If you want to access the elements by index, to my knowledge the only option is a Java Snippet or a Java Snippet (Simple). For example, using the following code in a Java Snippet (Simple):

return $MyColumn$[0];

should give you a new column with the first element of your list.

2 Likes

Hi there!

Column Expressions node can manipulate with lists pretty good. There are around 20 functions inside it so take a look :wink:

Br,
Ivan

3 Likes

Thanks Aswin, I needed to know if such an option existed for when I am faced with referencing data structures like lists or dictionaries.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.