Hello team,
We have a Extracted Data defined in Below format
E_no
IN3
INa
IN2
IN1
INc
INb
YNc
Then
Reorganize in Below format
(The last character first in numerical ones are sorted and then alphabetical one)
i.e in E_no the last character (1,2,3,a,b,c as below given as example)
E_no
IN1
IN2
IN3
INa
INb
INc
YNc
Thanks Team in advance
@NISHITHA
-Assign activity:
-InputList = {“IN3”, “INa”, “IN2”, “IN1”, “INc”, “INb”, “YNc”}
-Assign activity:
OutputList = InputList.OrderBy(Function(s) If(Char.IsDigit(s.Last()), s.Last(), Char.MaxValue)).
ThenBy(Function(s) If(Char.IsLetter(s.Last()), s.Last(), Char.MinValue)).ToArray()
-Output Data Table
ppr
(Peter Preuss)
December 12, 2023, 8:01am
3
Looks similar to the already answered topic
we can exploit that the asc code from a number is below of a char. So we directly use OrderBy on the last char
[grafik]
And Also:
[grafik]
ppr
(Peter Preuss)
December 12, 2023, 8:18am
4
When an adaption to a datable is needed
Assign Activity:
dtSorted | Datatype: DataTable =
(From d In dt1.AsEnumerable
Let oc = d("E_no").toString.Trim.Last().ToString
Order By oc
Select r=d).CopyToDataTable
@Dilli_Reddy and @ppr
Thanks for the quick responses
Have tried both the approaches but we get sequence contains no elements exception
Is it because of Blank fields with “” that exist in below format along with data
Example
InputList = {“IN3”, “INa”, “IN2”, “IN1”, “INc”, “INb”, “YNc”, “” ,“”, “”, “” ,“”, “”, “” ,“”, “”}
ppr
(Peter Preuss)
December 12, 2023, 8:48am
6
So we could adopt
(From d In dt1.AsEnumerable
Let oc = d("E_no").toString.Trim.LastOrDefault().ToString
Order By oc
Select r=d).CopyToDataTable
we are not sure if the “” values will cause
when scenario is described as above, we would doubt it.
But just let us know, on how the blanks should be handled (filtered out, at the end, at the begin). Also let us know if your input is a datatable (as mentioned above within the topic description) or a list (as mentioned in your last feedback)
Hii @ppr
Let me explain in a better format
Its actually a data table with Various columns
Example
Columns Such as E_no , TextData , DateFromStart ,etc
E_no , TextData , DateFromStart
We can actually remove “” from data table
As they are Blank Rows
Also what we are try to achieve basically is when we rearrange column E_no
At the same time corresponding columns row data will also get shifted
ppr
(Peter Preuss)
December 12, 2023, 8:59am
9
we would recommend the following:
scope the topic to a predefined use case a
redefine the usecase / requirement description
along with data samples (representing in complete the structures and value variations)
expected output sample
Based on this, we can check for a matching solution suggestion
Hello @ppr
Have added Remove Blank Rows and then added the approaches Suggested
Its Working for Restructuring the Column
Regarding the other query as suggested will define usecase appropriate way
Thanks @ppr and @Dilli_Reddy
system
(system)
Closed
December 15, 2023, 10:22am
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.