How to convert text to datatable

I get data from Get full text output, can anyone help convert it to datatable format?
score.txt (63 Bytes)


Hope the following helps you.

System.Text.RegularExpressions.Regex.Replace(strScore,"([^\r\n]*)\r?\n([^\r\n]*)\r?\n([^\r\n]*)\r?\n",Function(m) m.Groups(1).Value+","+m.Groups(2).Value+","+m.Groups(3).Value+vbCrLf)

Sequence.xaml (5.5 KB)




Welcome to the UiPath Community

Another approach without using Regex and Generate Data Table Activity

Follow the Steps

  1. Read Text File to store it into the string variable (tableText)

  2. Build Output Data Table


  1. Use Assign activity to convert the string into array of words


arr = Strings.Split(tableText.Trim, Environment.NewLine)
  1. Use Assign activity to convert the string into data table


outDT = (from i in Enumerable.Range(0, Cint((arr.Count)/3)).Select(Function (n) n*3).Skip(1) Select outDT.Rows.Add({arr(i), arr(i+1), arr(i+2)})).CopyToDataTable
  1. You can view the output using the Output Data Table Activity or use write range activity to write the outDT to excel file.


Create Data Table from Text.xaml (7.6 KB)

1 Like

@Yoichi Thanks for your help. It worked. :smiley:

@kumar.varun2 Thank you for your solution and detailed explanation. My problem has been solved. This is my first topic, your help makes me have confidence in the future.


Feel free to post your problems on this forum.

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