I m having a excel file having a column name with specific data values into it. i want to get the whole data value into string variable.
For example
Column Name - SrNo.
Data Value - 1
Data value - 2
I want to fetch only numbers as results at once
Use the following LINQ:
dt_input.AsEnumerable.Select(Function(x) x("SrNo.")).ToArray
And then you can join the array into a string with String.Join (String.Join Method (System) | Microsoft Learn )
what must the variable type? i do not want to use for each to extract this data
vrdabberu
(Varunraj Dabberu)
April 9, 2024, 5:48am
4
Hi @tejas.kotharkar
=> Read Range Workbook
Output-> dt
=> Use below syntax in Assign activity
srNoValues = String.Join(", ",
(From row In dt.AsEnumerable()
Select row.Field(Of Double)("SrNo")).ToArray())
srNoValues
is of DataType System.String
Regards
Hi @tejas.kotharkar ,
There isn’t anything wrong with using For Each, however the solution provided by @ignasi.peiris doesn’t require a For Each and you just have to assign it to a string variable.
Kind Regards,
Ashwin A.K
Linq does not use ForEach:
That results in an Array of Int (As they are numbers) but can be converted into an array of strings, to then join them in a string:
Activity: Assign
Left = arr_stringValues
Right = dt_input.AsEnumerable.Select(Function(x) x("SrNo.").ToString).ToArray
2nd Activity: Assign
Left = str_JoinedValues
Right = String.Join(“,”,arr_StringValues)
In addition, you can do everything in a single assign like so:
Activity = Assign
Left = str_JoinedValues
Right = String.Join(",",dt_input.AsEnumerable.Select(Function(x) x("SrNo.").ToString).ToArray)
Hope this helps!
Exactly, But Its giving error value of object cannot be converted to string after keeping the variable to string
vrdabberu
(Varunraj Dabberu)
April 9, 2024, 5:54am
8
Hi @tejas.kotharkar
=> Read Range Workbook
Output-> dt
=> Use below syntax in Assign activity
srNoValues = String.Join(", ",
(From row In dt.AsEnumerable()
Select row.Field(Of Double)("SrNo")).ToArray())
srNoValues
is of DataType System.String
Check the below image:
Regards
I’d say you should double-check your variables, as I just tested it, and looks to be working…
TestJoin.xaml (7.7 KB)
i want only numbers as a extraction
i do not want to join them
vrdabberu
(Varunraj Dabberu)
April 9, 2024, 5:59am
12
Hi @tejas.kotharkar
Can you specify what is your expected string output.
Regards
then just use
That will return an Array of Strings
vrdabberu
(Varunraj Dabberu)
April 9, 2024, 6:02am
15
Hi @tejas.kotharkar
Do you want to change the format of a column. Intially it would be in number you want to change it to string. Is that right specify.
Regards
i want to extract column values from a column.
i tried using linq and i was unable to do it as it giving error in varaiable assigning
yes tried but unable to get the solution
vrdabberu
(Varunraj Dabberu)
April 9, 2024, 6:10am
18
Hi @tejas.kotharkar
srNoValues = (From row In dt.AsEnumerable() Select row.Field(Of Double)("SrNo")).ToArray()
srNoValues
variable is of DataType Array(System.Double)
Output
Sequence.xaml (9.3 KB)
Regards
system
(system)
Closed
April 12, 2024, 6:10am
19
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.