Removing character from column

How to remove a character from any column of datatable without using “foreach” loop.

Hi @syedabidraza
buddy

Use Dt.Columns(“ColumnName”).ColumnName=“your Column Name”

Thanks
Ashwin S

for example
ID is column name
1,234
2,345
3,456
4,567
it should remove all the comma(,) from the column ID

@syedabidraza

  1. use Read Range activity to read the data from excel file and will give you output as DataTable and say ‘DT’. And then use ForEach Row activity to iterate one by one row.

     ForEach row in DT
         row("ID") = row("ID").Tostring.Replace(",","")
    

And then finally use Write Range activity to write into excel file after ForEach row and pass that DataTable ‘DT’.

Hi @lakshman
He is asking without for each row activity

Thanks
Ashwin.S

@AshwinS2 - sorry I didn’t see that one.

@syedabidraza

Try below expression.

                    DataRow []  newValues = datatable.AsEnumerable().Select(Function(row) row("ID").ToString.Replace(",", "")).ToArray
1 Like

Hello

How would you write the expression for removing a character from a list under a column for e.g.

Column1
123,4
123,5
123,6

and removing the ,

@Cormac
Can you please Open a new topic and give some Details and Sample data along with your question? Thanks

why create a new if the question is the same and already answered by lakshman?

let decide @Cormac if his question is answered.

you can use like this in a invoke code, pass in your datatable as input/output:

datatable.Select.ToList.ForEach(Sub(Row) Row(“Column’”) = CStr(Row(“Column’”)).Replace(“,”,“”))

1 Like

Thanks for your help. Do I use that with an assign activity?

no that should go inside an invoke code as it is not a function…

Apologies is it an invoke Activity?

like this:
image

1 Like

Thanks again for your help. I am getting the following error though

Just to give you more context of what my sequence looks like (below)

you have data type as string, need to change to datatable

1 Like

Yeah I noticed that and changed it to datatable. When I run its throwing the following error. Sorry for all the questions. I haven’t used this invoke before

image

you cant just copy and past from forum when it have double quotes because it gets errors… inside your Invoke Code activity delete and type it back.

Yes. I didn’t paste but it still gives me the same error