String table to string

Hi All,

I have a string table which has three columns (eg. Fname, Lname, Email). Lets assume this string table has about 10 rows in it. I am looking for a way to traverse through this string table and create a string variable out of it which would look like:

Fname1, Lname1, Email1; Fname2, Lname2, Email2; Fname3, Lname3, Email3;…

and so on.

I would also not mind it if I could instead store these values on a string list such as:

Fname1, Lname1, Email1
Fname2, Lname2, Email2
Fname3, Lname3, Email3

Fname10, Lname10, Email10

Any help is greatly appreciated.

Thanks in advance.
pENGUIN

Hello Penguin,

Use the service pub.table:stringTableToTable and pass your string table to this service and give the column names. This gives a Document List with the column names a fields. Then you can loop over this doc list and create your desired outouts: Add each field to a separate string list or form a string in your desired format.
I would appreciate, if you have already tried your own approach before posting here.

Cheers
Guna

1 Like

Hello Penguin ,

You could do the following steps.

Step1: Intialize a map in which you declare a var say finalList and set a value blank.

Step2: Add a loop over the source table (i hav taken the table variable as source.)

Step3: In a map inside this loop, intizalize a variable say tempList, and set its value to the following. %source[0]%,%source[1]%,%source[2]%; .

Make sure you check the Overwrite Pipeline and Perform variable substition check.

Step 4: Add a map inside the loop. In this set the value of finalList as
%finalList% %tempList%
Make sure you check the Overwrite Pipeline and Perform variable substition check.

After the loop is over, you will get your desired output in finalList var.

Hope this helps

Hussain

Hi Hussain,

Worked like a charm. I had already implemented it before you replied, but having said that your solution was so much better. Changed the implementation to the one suggested by you and works beautiful.

Thanks a bunch.

Penguin

Why not just write a quick Java service? All you need to do is convert String to String
Depending on the size of the data, Java service will have much better performance.

Writing a java service for a task that can be done with flow services is not acceptable. There are a lot many threads explaining why. You should go for them only if it can’t be done in a flow service or performance is a bottleneck.

Cheers
Guna

You could check this thread.
[url]wmusers.com

Hussain

The question was how to convert String table to String List… Now, doesn’t that sound like a simple utility service requirement? There’s nothing wrong in writing these simple utility services in generic fashion in Java and re-use it.
If the requirement was the typical integration type of service, of course, it should be done in Flow.

the question was how to convert a table of 3 columns to a string List and in a specific format specified. SO i guess its not an issue if done with a Flow. Moreover any manipulation inside the flow with the other data would be quite easy.