String to data table which prints 1 object per line

Hey, I have string “1 2 3 4 5” and I want create data table with 5 rows which all contains 1 number. What’s best way to do that?

1 Like

hope these steps would help you resolve this
Str_input =“1 2 3 4 5”
—now assign activity with a array of string variable
Arrinput = Split(str_input,” “)
—now create a datatable with build datatable activity and create only one column and get the output with a variable of type datatable named dt
—now use a for each activity and pass the input as arrinput and change the type argument as string in the property panel of for each activity
—inside the loop use a ADD DATAROW ACTIVITY and in the ArrayRow property mention as {“1”} and in the datatable mention as dt

That’s all you are done
Cheers @Darba


Hey thanks for help and I got a lot idea what you tried get me to do and I think I got it done. Somehow I don’t get anything to the output when I run the file:arraystringtest.xaml (7.4 KB) @Palaniyappan

@Palaniyappan arraystringtest.xaml (7.5 KB) for some reason I don’t get any output from this.

Where are you checking for the output in the sequence attached @Darba?

1 Like

I run the file in slow motion and get goes well but Im lookking to get it printed to the datatable as
So there’s 1 number per 1 row.

arraystringtest.xaml (7.7 KB)
check this xaml, updated the add row part, check that for your understanding

1 Like

code is absolutely correct, you just need to add {item.ToString} for ArrayRow in the property of addDataRow activity
after that you may write dt in an excel file

1 Like

@sarathi125 Thanks a lot if I want to sort the string numbers in descending order what would be best way to do that? I tried add new assign and put select.dt(“Name Desc”) on it but it didn’t seem to work.

In the for each loop change like this

fiveString.OrderByDescending(Function(a) a)

Updated the xaml as well arraystringtest.xaml (7.7 KB)

1 Like

That seems to work only problem is that if I go to numbers over 10 then it thinks that 10 is between 1 and 2. Any fix to that? @sarathi125

use this in the for each loop.

fiveString.OrderByDescending(Function(a) Convert.ToInt32( a))
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.