Write Range to CSV or Excel

Please help if you can.

UC: Need to scrape a number from a webpage and write that scraped number back to CSV or Excel file.

Current flow (WORKING):

  • Read CSV
  • Open Browser
  • Login
  • Read Each Row
  • Enter search criteria and advance to next screen
  • Scrape number

Above flow works


  • Write number to CSV or Excel


  • Repeat for each row in CSV or Excel

I have tried a lot of Activities such as Assign, Write Range and Output Data Table but not sure I am using these correctly.

Any help would be wildly appreciated.

hi @JAC
while looping the data use Build Datatable Activitiy
and add data row activity
and then print the values in output datatable
and then use write range activity

Ashwin S


A good approach will be adding all of your numbers to a dataTable and then when you finish scraping write that whole dataTable directly to the CSV file.


Hi @reda and @AshwinS2

Thank you for your suggestions. Attached is the flow that currently works. This is only processing a single record in the CSV and correctly writing the scraped number to an Excel. However, imagine you have multiple rows within the CSV that need to be processed.

1.2 DEMO Zipped.zip (400.4 KB)

The test data has been changed for security purposes so if you run the process it will fail. I’ve tried both suggestions and I believe that they should work. However, I am not sure I am putting the Activities in the correct places within the sequence/workflow.

Hi @reda and @AshwinS2

I tried both of your suggestions but neither worked. I believe there are details missing in your instructions. Could you please provide more detail?

Let’s suppose the output of read csv is a datatable dTable. Add a new data column to this dTable. Add the scraped values of each data row to this data coloumn. Using write range activity write the entire dTable to csv. Hope this helps.

What they were saying is that you should not add each row 1 by 1 to the excel or CSV. Instead, you should create a new datatable, then add each row to that new datatable. Once you are done iterating through everything, then use the write CSV or write range activity to write the entire new datatable to the CSV/Excel file at the end

Hi @Dave

Sorry my follow up wasn’t clear. Yes, I understood what they were saying. However, I tried their suggestions and neither worked.

I have attached the flow above that actually worked. Please feel free to make the applicable changes and send it back once it’s in working order for my review.

Again, I tried the suggestions above and they did not work. Those attempts are not included in the attached, above, flow. The flow above is only what is currently working and not the end goal.

Help is appreciated.

I am unable to see anything as I am using studio 2018.4.3 and you are using activity packs that are not backwards compatible for me. I have however created a simple example showing that it does indeed work and is the recommended way due to speed :slight_smile: Let me know if you have questions.

Assumptions: You want to add the information to the columns that exist in the CSV that are currently blank (column name = PA_MBINumber)

JAC.xaml (9.9 KB)

Hi @Dave

Thank you for the file and example. It did work, however, there was certainly details missing from the suggestions above.

  1. Use “For Each Row” instead of “Read Each Row” activity
  2. UiPath.Excel.Activities.WriteRange does not need to be included in an Excel Scope

These two changes made all the difference. Thanks again for your help.

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