Remove Last Character Each Row from Read Text

Hi, good day,

I have a text file contains

ABC|123|456|
ABC|123|456|
ABC|123|456|

how can I remove the last character “|” of each row?

Im using generate data table with | as column separator but it still recognize the last character as another column.

Thank you.

@chakri

Try this:

row(“ColumnName”).Tostring.remove(row(“ColumnName”).Tostring.length-1)

Or

row(“ColumnName”).Tostring.Remove(row(“ColumnName”).Tostring.LastIndexOf("|"))

thanks for response. it is text file so it does not contain any column. i already try Length-1 and Remove with LastIndexOf, not working…it only remove the last row only

@chakri

Oh ok. I thought it is from Excel file.

Use Read Text file activity to read the text and will give you output as string and store it in a variable if type string and say ‘readText’. And then use following expression:

readText.split(Environment.NewLine.TocharArray)(0).remove(readText.split(Environment.NewLine.TocharArray)(0).length-1)

And same way do for all lines.

1 Like

Hello @chakri for one liner code you can use below as well…

String.join(Environment.NewLine,(from x in str.Split(Environment.NewLine.ToCharArray,StringSplitOptions.RemoveEmptyEntries).ToList select y =Left(x.ToString,x.ToString.Length-1)))

1 Like

Hi @chakri
Please find the Attachment it will help youTextToDatatable_RemoveChar.zip (13.2 KB)

1 Like

Hi all,

thanks for wonderful reply. all solution replied working out well. for anyone see this question, you can download attached workflow from @jitendra_123 .

Thank you and appreciate it !

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