Help with writing values from one data table to another Data table

Hi Experts,
I am looking for some help regarding writing a value from one data table into another and finally writing it to excel.
I have list of urls in excel that I am reading and then iterating using for each loop. From each url, I will be getting data in the form of data table.I need to write each url and corresponding data table in excel. For now I am just creating an empty row for each run to differentiate an entry as I am unable to figure out how to write the url corresponding to the data table. Attaching screenshot of the bot. Any help is greatly appreciated.

Hi @Mchande,

Have you tried append range?

If you want to add datatable to same excel, you can use Append range activity.

Hi @Harshith_Adyanthaya - The input and output excel are different.

Hi @Mchande

ExtractDataTableDetails will already have the datatable from each urls. You can write the same data into different sheet or file in the loop, where you don’t need any add Datarow activity.

If your objective is to add all datatable one below the other, you can declare a master datatable outside the loop & everytime you extract a url data, append that to the master table using Append Range activity.

Hope this helps,
Best Regards.

Yes, I am not suggesting to append to input file. Since there are multiple datatable, you can use one output excel file and append all datatable to it.

Yes, thats what I am currently doing. I also need to make sure the datatable is for a specific url. Attaching screenshot of the entire flow.

@Mchande

Build a datatable outside the loop with same structure as extracted datatable.

Inside the loop, instead of add datatow, use append range to append each url to the master table. You can add a differentiator datarow in between extracted tables.

Hope this helps,
Best Regards.

Hi @arjunshenoy - How will I write both url and its corresponding data table to new table? I dont need to write the empty row if I am able to write url

Hi @Mchande

You can write the url {“Url”} instead of empty row.

@Mchande

Let’s say your extracted datatable has 3 rows, in that case, you can design a differentiator row like:

{currentURL.ToString,””,””}

Add this row first & then append the extracted dt range.

Hope this helps,
Best Regards.

Hi @Mchande

To write the URL corresponding to the data table into Excel, you can use the “Add Data Row” activity to add a new row to the data table before writing it to Excel. Here are the steps you can follow:-

  1. Create a new data table with two columns: URL and Data.
  2. Inside the for each loop, use the “Extract Structured Data” activity to extract data from the URL and store it in a data table.
  3. Before writing the data table to Excel, add a new row to the data table that includes the URL. You can do this using the “Add Data Row” activity. Set the values of the row to an array that includes the URL and the data table.
  4. Write the data table to Excel using the “Write Range” activity.

Hi Nitya - The data extracted from the url into the data table has 3 columns in it. In my for each loop I already have the corresponding url in “Currentrow”. I just need a way to write it.

You can achieve this using a For Each Row activity, as follows:

  1. Drag and drop a For Each Row activity into your workflow.
  2. Set the Input property of the For Each Row activity to your DataTable.
  3. Inside the For Each Row activity, add an Assign activity.
  4. In the To field of the Assign activity, enter the column name where you want to write the URL.
  5. In the Value field of the Assign activity, enter “CurrentRow(“ColumnName”) = URL”, where “ColumnName” is the name of the column where you want to write the URL and URL is the variable that holds the corresponding URL for the current row.

@Mchande

Add a row by using the activity add datarow & pass this array items into the row.

Best Regards.

Hi @arjunshenoy - Thanks a bunch. I am now able to get the url in the output. It just comes after the corresponding data table extract.

1 Like

@Mchande

Glad you figured it out. Happy Automation!

Best Regards.

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