Convert from string to DataTable

Hi.
I have the following string: 17 45 65 2 7 8 4
a. how do I make it a DataTable?
b. how do I remove even numbers?
c. how I order the numbers from least to greatest and again I transform them into a string?
Thank you so much.

Hey @Joselito_Jimenez

I hope you’re well.

Here are the steps I’d follow:

  1. Build datatable
  2. Assign activity to split the string into an array (splitting by spaces)
  3. If statement compare number (convert string to int) to mod 2 = 0. This tests for even numbers.
  4. Add Data Row activity
    • In the property window you can find ArrayRow, add your array in that field
  5. Sort data table

Hope that helps.

Hi,

Hope the following helps you.

a. how do I make it a DataTable?

Can you try Generate Datatable activity with the following settings

CSV Parse : true
Column Separator : " "

b. how do I remove even numbers?

Let’s say str="17 45 65 2 7 8 4"

strRemoveEven = String.Join(" ",str.Split({" "c}).Where(function(x) Cint(x) mod 2 =1))

c. how I order the numbers from least to greatest and again I transform them into a string?

strOrdered = String.Join(" ",str.Split({" "c}).OrderBy(function(x) Cint(x)))

Regards,

1 Like

Thank you @Jacqui_M.

Thank you @Yoichi

1 Like