Read CSV- 'row is not declared. It may be inaccesible due to its protection level'

I want to read data from CSV file and enter the same in the fields of web application (Data driven). I am using Read CSV concept. Following below steps:

  1. Added Read Csv and declare one variable for Output (dtLogin) as System.Data.DataTable
  2. Added ‘For Each Row’ (Foreach row in dtLogin)
  3. Added ‘Write Line’ in the body of For Each Row and call the first row first value in the same as row(“CorpCode”).ToString
  4. Added the same ‘row(“CorpCode”).ToString’ in the actual Type into ‘INPUT’ activity.

I am getting error ‘row is not declared. It may be inaccesible due to its protection level’.

Kindly suggest.

@prajakta.waje, The scope of object row is confined within For Each Row. You can use it within for each row and apparently can’t use it elsewhere (as stated in error message).

Example When an item is sealed and locked in a room obviously we can’t see it outside .

Requesting you to have a look into Uipath Academy and lesson 9 - Excel Automation to have detailed and clear idea

Dominic :slight_smile:

If you want to access outside foreach scope then just assign it to a variable(with proper scope where you have to use) and then access it where ever you want.


It is working :slight_smile: … Thank you for your instant reply…

Now I want to execute the csv file for multiple rows. for ex. if I want to run the script multiple times (say 5 times)… There will be 5 rows in CSV and for every run it should take different row data (row 1- row 5)… Can you help me out to solve this. Do i need to use For loop … If yes then how? else please share tutorial link related to this scenario


As mentioned earlier.

Also follow this link Excel Automation

Dom :slight_smile:

I tried this earlier but I am not able to login in this with same credentials… And there is no option for singing up.

@prajakta.waje, Do you have login credentials (separate) for UIPATH academy ? Any issues faced while login/sign up shall be notified same to the academy team.

Dom :slight_smile:

Link is not available for TRAINING MATERIAL- lessons in Uipath Academy. I can search lessons but hyperlink has not been provided for the same. I have checked Excel automation video, but it has shown only excel to excel automation.

My question is: I want to capture data from CSV and enter it in web application for multiple rows. Currently I am able to do the same using read csv as mentioned in first post but only once. If I want to execute it multiple times with different rows data from the same csv, how should I move forward?


Once again check the links, if its not available you can inform academy team.

Hope you have used For Each row already. Inside the body of for each, you can get each row value by row(“ColumnName”).ToString. Usage of for each row has been explained in the video finally.

Kinldy go through our forum posts we have many solutions

Dom :slight_smile: