DT manipulation scenario: feasible in UiPath or need a code activity?

Hi guys,

I need to do a relatively complicated data table manipulation as a part of a solution. (Complicated, based on my initial efforts at solving it. . . I’m sure the gurus out there might think this is a piece of cake.) I would really appreciate some advice from more experienced developers on whether I should use my time do DT manipulation with data table activities or do a code activity (which I have never done). Any tips or ideas on how to actually execute the dt manipulation would be much appreciated as well.

Below is a s/c of the before (upper table) and desired after (lower table). The number of records in the before table will probably vary each time the automation is run. Please note the colors to help map the fields from before and after table.

Thank you!
ShelbyDT manipulation help.xlsx (18.5 KB)

Yes can be done with essential activities. Have a look here
Shelby_Pons.xaml (10.5 KB)

1 Like

FIRST_COLUMN_IDX = 5 (index of column “a”)
MARKER = “X” (content of a “ticked” cell)

  • Build DataTable dt_After

  • ReadRange to dt_Before.

  • ForEach column in dt_Before.Columns (type: DataColumn):

    • If column.Ordinal < FIRST_COLUMN_IDX:

      • continue
    • Assign filter = String.Format("{0}='{1}", column.ColumnName, MARKER)) (type: String)

    • ForEach row in dt_Before.Select(filter) (type: DataRow):

      • AddDataRow to dt_After
  • WriteRange from dt_After

1 Like

Thank you for the quick response! I didn’t expect to get such great answers so quickly.

Thank you!! This .xaml file worked for me with the official data which includes about a dozen rows.

The only issue I ran into was the error “Index is outside the bounds of the array” when using a write range to display dtData2 when running the sequence on my client wb, which includes other tabs. If I created a copy of the client wb target sheet and copied into a blank wb (without the other worksheets in the workbook), it would work. For some reason the other sheets were messing up the execution.

The solution I figured was to simply copy the target worksheet to a blank workbook when executing the sequence, which works great. Just out of curiosity, I’d like to know any solutions you can think of to be able to run it on the worksheet within the workbook…

Thank you either way!

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