Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
danped
Contributor
Contributor

Take comma separated string and input into list

Hi,
I have a string input as a context (myContext = "item1,item2,item3,item4") and I want to be able to iterate over the comma separated values. I have used a tNormalise component to separate out the elements of the string but can I load these into an array so that I can create an iterative loop and do something with each element?
Thanks,
Dan
Labels (2)
4 Replies
Anonymous
Not applicable

Yes you can. If you are receiving them in a context variable, you can use a tJavaFlex. Convert them to an ArrayList in the Start Code section and then open a While loop in that section. Use the Main Code section to do whatever you want to do with the ArrayList (maybe output a row for each value?) and then close the loop in the End Code section.
Although I am not doing precisely this in this tutorial ( https://www.rilhia.com/quicktips/quick-tip-row-multiplication) it demonstrates how you can generate rows using a tJavaFlex. If you have some Java, you should be able to extrapolate.
vapukov
Creator III
Creator III

You can do as described above with tJavaFlex,
as alternative You can use 
tInputXXX -> tNormalise -> tFlowToIterate  and then continue work with single element in Loop
tInputXXX -> onSubJobOk - will continue Job after finish the loop
danped
Contributor
Contributor
Author

Thanks both, vapoukov's method works a treat and avoids me using any java. Rilhia Solutions looks like a great resource - thanks.
Anonymous
Not applicable

I have also come across this scenario, I have fixed my issue by using below flow

trowgenerator> tnormalize > tflowtoiterate > tjava

[Note: In tRowGenerator you have to get the context variables ,which you have in your configuration file.Then In tnormalize component  separated by comma ]