Generate a datatable from a string

Sample Input String :
• Ronaldo
• Messi
• Bavuma
• Pique

I need to generate a datatable with one column and 4 rows without the bullet point.

@Tanmay_V_Chetule

Use a replace first to replace dots and then use a generate datatable with cav prsing

Cheers

Hi @Tanmay_V_Chetule ,

Thanks for reaching out UiPath Community.

You can follow below steps:

  1. Replace Dots with empty strings.
    image
  2. Split the String with Space and Store it in an Array of strings.
    image
  3. Use Build Data Table.
    image
  4. Use For Each Activity to iterate and Use add data row to add a row in the data table.
  5. After completion you can use Outputdatable to Get Output.
    image

Hope This works for you.

Happy Automation,
@Vinit_Kawle

1 Like

Hi @Tanmay_V_Chetule
=> Use the below in Assign activity:

inputString= "• Ronaldo 
              • Messi 
              • Bavuma 
              • Pique"

=> Use the below code in Invoke Code activity:

inputString = inputString.Replace("• ", "")
YourDataTable = New System.Data.DataTable("PlayerData")
YourDataTable.Columns.Add("PlayerName", GetType(String))

For Each player In inputString.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
    YourDataTable.Rows.Add({player.Trim()})
Next

=> In the Edit Arguments option give in the below way:


=> Use Output Data Table activity and pass the datatable and store the output
=> Print it in Message Box

Attached the workflow for better understanding:
Sequence1.xaml (9.1 KB)

Hope it helps!!

Hi @Tanmay_V_Chetule ,
You can replace line breaks to spaces
my input/output


we need change only default to

hope it help
my source
ExcelActivity.zip (9.1 KB)

regards,

As An alternate (one of many other options)

OR

  • use generate Datatable