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)
dt

Hi,

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)

Regards,

2 Likes

@tonyyang

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

image

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

image

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

image

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.

Attachment

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.

@tonyyang

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.