Replace using LINQ Query

Hello everybody!
Can you please tell me how to replace commas with periods in a column using a LINQ query?
For example, there is a column “Column1” in it numbers of the format “12334,12”, as with the help of LINQ query replace with “12334.12”.
An example of my requests:
assign dt = dt.AsEnumerable (). Where (Function (a) a.Field (of string) (“Column1”). ToString.Replace (“,”, ”.”). ToString) .CopyToDatatable () - option error strict on disallows implicit conversions from ‘string’ to ‘boolean’.
assing dt = dt.AsEnumerable (). ToList (). ForEach (Sub (row) row (“Column1”) = row (“Column1”). ToString.Replace (",", “.”)) - error expression does not produce a value.
Thanks.

Hi

Please try below steps,

  1. Read the excel sheet data in the datatable variable name dt.

  2. Drag and drop the invoke code activity.

  3. In edit arguments, create a variable dt, set direction as in/out and pass value as dt.

  4. In edit code type the following,

dt.asenumerable.tolist.foreach(sub(row) row(“Column1”)= row(“Column1”).tostring.replace(",","."))

Write the datatable back into the excel using write range activity.

We have to use this inside invoke code as it does not produce a output.

Hope this helps.

Thanks

1 Like

Tried it, but an error occurs in the invoke code - Exception has been thrown by the target of an invocation.
Please take a look.
Main.xaml (5.1 KB)
sample.xlsx (8.0 KB)

Hi @sereganator

Did u tried this

dt.AsEnumerable().ToList.foreach(Sub(row) row("Column1")= row("Column1").tostring.replace(",","."))

Regards

Nived N :robot:

1 Like

@sereganator I can’t open the file in my laptop due to restrictions can you please share some screenshots of the workflow.

Thanks

Yes, tried this, but error.

Make sure the datatable has been passed in the invoke code correctly, make sure the column name matches with the excel.

Else try this also

dt.asenumerable.tolist.foreach(sub(row) row(0)= row(0).tostring.replace(",","."))

Thanks

Ok)


Have you passed the output of read range in value of invoke code argument?

It seems empty.

Thanks

Transferred.

@sereganator
Have you enter dt in this field.

Thanks

I apologize for the inattentiveness, I really did not convey it. Thanks.

1 Like

No worries :slightly_smiling_face:

1 Like

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