Adding String data to datatable?

Hey guys, I have a string that is twelve words divided by one pipe character each “|”, I wanted to see what is the easiest way to put these into each of the 12 columns of a datatable I created? – is it necessary to make the string an array first or can the string just be split into the datatable in a for each row? Thanks.

1 Like

Hi ,
Have you tried Split function.
DT.row(X).Item(X)=ST.split("|"c)(0)
Where DT=Datatable , X = number of row and item , ST=string

Would that be placed inside of a for each row loop, or use a while loop with a counter? (I could have 2-6 rows depending on the data input I extract from)

@cssc
Yes , you can put it inside loop. please keep in mind that (0) at the end indicates first part of your string which then needs to be replaced by var.

Is there anyway to do this all at once, it looks like I’d have use 12 individual assign functions to target each column?

@cssc
That i have not tried myself, but instead of having 12 individual assign activities, you can make a loop 0-11 and place it inside the loop.
of course do it all at once would be the prefect solution :slight_smile:

@cssc
you can do this all at once if you use Add Data row activity. but i assume this is not what you need since you already have row in your DT. and that row needs to be updated , right?