How to convert data from a DT into a string format?

Hi everyone,

I want to convert a dt into a string format, the dt value is like:
[Column0
5 star
65%
4 star
17%
3 star
8%
2 star
3%
1 star
7%
]

Where I only got one column and one row, and I want to convert into this:

[5 - 65%]
[4 - 17%]
[3 - 8%]
[2 - 3%]
[1 - 7%]

How can I do that ??

Hi @marquezd

=>


Output → dt

=> Use the below LINQ expression:

finalString = String.Join(Environment.NewLine, dt.AsEnumerable().Where(Function(row, index) index Mod 2 = 0).Select(Function(row, index) "["+row(0).ToString().Split(" "c)(0) + " - "+ dt.Rows(index * 2+1)(0).ToString+"]").ToList())

Hope it helps!!

1 Like

It doesn’t work, because the only row contains all the information like this:

image

I put in an excel file beacuse UiPath does not allow me, but the information is all in row 0 in this case, any suggestions ??

Hi @marquezd

Is it throwing any error. As i have replicated the same data in Build Data Table as provided and the query works at my end.

Regards

Yes, it thows the error that there not value at position 1.

Hi @marquezd

Can you share the excel file you are using

Regards

example.xlsx (9.6 KB)
Sure, thats the excel File.

Hi @marquezd

Check the below workflow file
Sequence4.xaml (10.3 KB)

Hope it helps!!

Thanks a lot, it works but I hace to instaal some features to run

1 Like

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