I am quite new to the UIPath environment and also to coding and now I need your help because I just can’t get on with my problem. I am trying to solve the following in UIPath:
I read a *.csv file into a DataTable, then I have to delete all lines below the line with the last “SB” entry. There can be rows with other values above the rows with “SB” and below the rows with “SB” as well. The value “SB” is in the first column.
I hope it is understandable. I have attached an image of the CSV data, here the last 7 rows would be deleted accordingly.
your current data sample would serve the condition filter on CH, SB
we can do it with the Filter DataTable Activity
But if a new Dataset will have other Values above the last SB, then the implementation will differ from requirement: delete all rows below of last SB
Implementation of Delete all rows below last SB (minimal implementation)
Assign acitvity:
LHS: idxLast | DataType: int32
RHS: yourDataTableVar.asEnumerable.ToList.FindLastIndex(Function (x) x(0).toString.Trim.Equals("SB"))
it will return -1 when no SB was found