Hi all,
Question- Linq query to check if the column value has quotes and if present replace it with blank.
Ex-
Input
column1
ABC
Def
“Xyz”
Output
ABC
Def
Xyz
Any idea?
Thank in advance.
Hi all,
Question- Linq query to check if the column value has quotes and if present replace it with blank.
Ex-
Input
column1
ABC
Def
“Xyz”
Output
ABC
Def
Xyz
Any idea?
Thank in advance.
Hi @Ray_Sha1 ,
Are we Checking for Specific Columns or all Columns ? Also Do you want to Replace Quotes only at the Start/End or if it is present anywhere in the String ?
Check below for your reference
Use Invoke code and write as below
dttt.AsEnumerable().ToList.foreach(Sub(row) row("Column1")= row("Column1").tostring.replace(""""," ").Trim)
Hope this will help you
Thanks
Hi @supermanPunch,
Specific column called column 1.
Quotes are present in the start and end.
Thanks!
In Invoke code you need to use create an argument and pass the datatable, Direction should be In/Out
Thanks
@Ray_Sha1 ,
Though we would suggest to use For Each Row
Activity and Update values accordingly, since it is a Simple Update, the below Steps maybe an alternate method to get the Required Result :
Assign
Activity.columnNames = DT.Columns.Cast(Of DataColumn).Select(Function(x)x.ColumnName.ToString).ToArray
Here, columnNames
is the variable of type Array of String, DT
is the Input Datatable.
OutputDT = DT.Clone
Assign
Activity to remove the Quotes at the Start/End.OutputDT = (From x In DT
Let ra = columnNames.Select(Function(c)If(c.Equals("YourSpecificColumnName"),x(c).ToString.Trim("""".ToCharArray),x(c).ToString)).ToArray
Select OutputDT.Rows.Add(ra)).CopyToDatatable
Let us know if this doesn’t work.
Hi,
The first query has an issue with it.
Thanks
lets append asEnumerable: From x In DT.AsEnumerable()
Could you Let us know what was the issue faced ?
Ppr helped you with it. The query is faulted and we’ll have to use asenum
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.