How to update specific row in data table

excel
uiautomation

#1

Hi guys,
I have a table with phone numbers as phone_table={911111111111,2222222222,913333333333,914444444444,5555555555}. now i have to add 91 before the 10 digit phone numbers… and i have to update the phone_table. The output should be like phone_table = {911111111111, 912222222222, 913333333333, 914444444444, 915555555555}.

Please guys help me if you know


Changing a row of a datatable iwth a given condition
#2

Hi @Sunitha_Bist,

You need to loop through entire datatable using “For each row” activity and then in the sequence you need use assign as :

row(0).ToString = “91” + row(0).ToString
row(1).ToString = “91” + row(1).ToString
row(2).ToString = “91” + row(2).ToString
.
.
row(n).ToString = “91” + row(n).ToString

for all the columns.

Regards,
V


#3

hi vikas.Jain
Thanks for your reply,
I dont need for all the rows because some will have by default as 91… So i gave If condition over there as if(row(0).ToString=10) then row(0).ToString = “91” + row(0).ToString… my question is that, how can i update in phone_table and it is not in column… it is in row wise in table


#4

@Sunitha_Bist, A table will surely have column and rows.

However with the example you have given, You can split the elements on the basis of “,” into an array/list, then append it with 91 and finally, assign it back to the same array or list.

Regards,
V


#5

thank you vikas.jain… it worked for me


#6

Here Take that all data into DataTable…Run a “For each Loop” for the data table and check
length=row(0).ToString.Length
if(length>10){
//Leave it

else

row(0)=“91”+row(0).ToString

}

Try with this it will work…