Maintaining DataTables in a loop For Each Row

Hello everyone (my first post here)

I’d like to ask for help:

I have a loop “for each row” and each item of the loop is used in a following sequence:

  • searching data on a specific website
  • web scraping of obtained data and saving it to a DataTable (called ExtractDataTable in my workflow)
  • modifying this dt by adding columns with specific data
  • appending this dt to a final excel file (called final_part_list.xlsx in my workflow)

What’s important, in the final file I need to have appended data from processing each item of the loop.

The workflow works fine only for the first item of the loop. Each next item causes fault in “Add Data Column” (it says dt already has the column I want to add) and in “Append Range” (it says that range does not exist).

I assume that I should use some kind of additional assignment when the loop starts in order to have the datatables reusable, but I have no idea how to do it.

ForEachRow.xaml (22.8 KB) download.xlsx (11.4 KB)

Hi @pboleszc
for the first issue: “Add Data Column”
After the first iteration the added Columns are already present in the DataTable. As Columns are to be unique same Columns cant be added again.

Give a try to add the columns before the each row loop.

1 Like

Exactly, you should use add row item. Create the column them add the values in the column.

1 Like

Thanks for a try, but it’s not so easy - in my case the dt is created in every iteration by web scraping, so I can’t add columns before adding values (or maybe it is possible but I don’t know how to do this?).

I changed the flow a bit by adding columns after the loop, in the end. The only disadvantage is that I will have a separate result file for every transaction item (the whole workflow is a part of a bigger loop with a queue)

I will try to have a look to your workflow in my evening. Please ensure that in 4 hrs from now on I can refer to your latest XAMLs

In the meanwhile: give a try on check if the additional columns are already present in the datetable and add them only in case the columns are missing

I had a quick look on your xaml.

General Suggestions:

  • prototype some activities in advance in seperate RnD sequences and explore the detail behaviour of the activities
  • With experience from this you can integrate in / or rearrange your workflow xaml

I saw the behaviour from ExtractData Activity used in a loop that the extracted result is added/merged to the previous retrieved Data. Just crosscheck this by yourself.
This should allow you:

  • to avoid the dumping and collecting part result into the temp.xls
  • after the final loop you could add the two datacolumns to all retrieved data in one go one one time
  • Writing all collected data at last in one go to “final_part_list.xlsx”

I have my doubts on write range without range information

the whole workflow is a part of a bigger loop with a queue

Here I do see a potential to split the xaml and integrate it via invoke worklow file. As I dont have seen arguments in use, it guess this is currently not done.

Thanks for revision & advices!

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