Need Clarification in String Split using delimiter (NewLine or '\n')

Team,
I am facing difficulties in extracting a data from a data table.
<Step 1 in attached image>
I need to split the above data using “Environment.NewLine” and append the same in string array, so used the below statement in Assign activity.
<Step 2 in attached image>
also tried like.
OUT_ExtractDataTable.Rows(0)(“Column-2”).ToString.Split(Convert.ToChar("\n"))
But i am getting output like below.
<Step 3 in attached image>
Please help me to get ride of this problem.

Image attached:

Regards,
Prabhu

Hi
Welcome to uipath community
Hope this would help you resolve this
OUT_ExtractDataTable.Rows(0)(“Column-2”).ToString.Split(Environment.NewLine.ToArray())

Cheers @Prabhumkpeak

2 Likes

@Palaniyappan, Thanks it worked out.
OUT_ExtractDataTable.Rows(0)(“Column-2”).ToString.Split(Environment.NewLine.ToCharArray())

For my understanding, can you please explain me the logic, Why It haven’t worked when i put Environment.NewLine alone…

1 Like

Great
OUT_ExtractDataTable is a datatable variable where Rows is one of the method of datatable and (0) is the row index while (“column-2”) denotes the columnname (we can even mention the column index as well) and Split is a method that helps us to remove the newline and convert them to array
with
Environment.NewLine.ToCharArray()

Hope this would help you
Cheers @Prabhumkpeak

1 Like

@Palaniyappan, Thanks for your clear explanation.
I have one question, why we need to put ToCharArray() while doing split operation

1 Like

it will convert them to array, once after removing the newlines
Cheers @Prabhumkpeak

Thanks a lot Palaniyappan

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