Solved

Add data to dataset from an iterative loop

  • 11 May 2024
  • 3 replies
  • 58 views

Badge +1

Hi everyone,

I have a loop set up that loops through records 50 at a time until the end of the day’s transactions. I would like to build a dataset of all records retrieved from each run of the loop to be exported to Excel. I thought about using a list but I cannot seem to find the right actions to append the data in within each iteration. Could someone give me some guidance or suggest a better way to attack this please?

TIA,

Steve

icon

Best answer by jon.stueveapeople 5 June 2024, 20:33

View original

3 replies

Userlevel 4
Badge +7

Generally, a data table will work best for this. You can add as many columns and rows to the table as you need. You don’t need to pre-allocate the table -- it will dynamically grow as items are added. If you need the rows in a specific order, be careful with the Data Table: Add row action. I’ve seen people use it incorrectly and get the order of their rows backwards.

Badge +7

Hi Steve,

 

You can utilize the log to file functionality where the data can be stored in comma separated values format or create a template of excel with the required fields that you want to insert the from the API Output.

 

Thanks,

Rajesh E

Userlevel 3
Badge +7

Both @Aaron.Gleason and @Rajesh E have good options. The easiest way is to use the Log to File method to write to a CSV file. Then outside of your loop, you can read from the CSV file into a Table type Variable, then insert those records into your Master Spreadsheet.

there are many ways to do this type process, using CSV, Excel, Database, or an in-memory DataTable per Aaron’s suggestion.

Reply