Loop through array and write in a data table?

I am new to this so I need your help. I have made an array called myArray from a txt document. I have mannaged to get the first string from that array into a data table, then I need to go back to string 2 to get all information inn that string into a new row in data table and so on to I have all strings writen in the data table.

1 Like

Welcome to uipath community
Hope these steps would help you resolve this
—we have the array variable named myArray and create a datatable named dt with the help of BUILD DATATABLE ACTIVITY with a single column created
—now use a for each activity and pass the above variable myArray as input and inside the loop use a ADD DATAROW activity
—in that activity mention the array row as {item.ToString} and in the datatable mention as dt

This will add all the value in the array to datatable in each row one by one

Hope this would help you
Kindly try this and let know for any queries or clarification

Cheers @kare.smorvik

I wil try. I have the data Table already so I need that string(2) fills out the next row, colum A to E. Then go back to string(3) and to the same and so on to all strings are filled inn my data table. I am not so familiar with for each, but I give it a go :slight_smile:

Fine buddy
but may i know how many columns are there in the datatable and how may values we are going to put it newly
cheers @kare.smorvik

1 Like

I have 5 colums, and in this case 9 strings, but when this is running properly ther could be many more. I have taken a screen shoot to show output when I write to excel.
Removed the name og the supplier and the purchaser :slight_smile:
I watched the priosess step by step and could see how it went thoryg the strings, but output in data table where the same.
Do I need to put all the activitis int for each, like all steps befor my For each, looks like it keep information from the first part and write it in the data table. Sorry about my english.

1 Like

Hi Palaniyappan,
Greeting of the day need one help can we use for each instead of for each row to read data table variable and can we store data table into an array so that we can use for each activity.

Yes you can use for each by keeping the argument as a Datatable.


hi Hasib08,
Thanks for the reply but still i am getting below message

1 Like

Hey Brother,

I have done exactly the same that you mentioned but getting error.

Plz have a check on screenshotimage

@Palaniyappan It worked. Thank you. :grinning:

1 Like