Not able to read every row, robot loops on first line of spreadhseet

Hello all,

Glad to be here. Very early days for me with using UiPath and I have a situation I wanted to get some help with. Please bare in mind I am a novice when it comes to automation and the options present in Studio.

In short: I have a Google spreadsheet with one column, every row cell contains a URL and I would like the robot to go through each cell, perform a set of activities (clicking on a menu, perform a file download and upload to GDrive) and then move to the next row.

The setup I currently use does work, but the robot only goes through the first row and loops.

The setup currently looks like this:

  1. For Each Row in Spreadsheet
  2. Read Cell
  3. Use Browser

I guess the problem is in the fact that I would have to provide to the Read Cell activity a variable from the For Each Row activity output. Even though there is an option to select a CurrentItem as a variable in the Read Cell activity I can’t figure out what to pick from the sub-options of the CurrentItem.

Any suggestions on how to do a better setup?
Thank you!

Adding a screenshot of the current setup.

Why are you using Read Cell? Getting the value of each cell in the row is inherent in For Each Row in Spreadsheet. Using Read Cell inside For Each Row in Spreadsheet is redundant and unnecessary.

Hey, thanks for the reply.

Okay, I can understand the redundancy but it was the only way to have the browser open the URL in the cell.

I am stuck on picking out a variable for the URL field in Use Browser (I would expect the CurrentRow to be the variable to be used, but it displays this message, screenshot below).

Any help with what should I pick from the CurrentRow variable options?
Screenshot 2023-02-21 at 17.07.10

You want CurrentRow(“columnName”).ToString

My Google spreadsheet only has one column (A) and no header. How should I format your suggestion? I just want the robot to run through column A, rows 1-150.

I tried the following and failed

CurrentRow(“A”).ToString
CurrentRow(“A:A”).ToString

Sorry if I’m asking silly stuff :slight_smile:

@nxr

Please use currentRow(0).TOString

0 is the column index

Range is something you specify in the for each directly

cheers

1 Like

Thank you Anil_G, the robot now goes through all the rows in the spreadsheet but I have another problem:

As it saves the file from every opened page locally and uploads it to a Gdrive folder, this only works correctly for the first 2 files in the spreadsheet.

Even though we can see in the stream that it opens the correct page and downloads a different file, each time, the 3rd uploaded file and the ones that follow are actually the 2nd downloaded file, every time.

Hopefully I explained correctly.

If there is no header and only one column, then you can just use CurrentRow(0).ToString

The 0 is the column index. First column is 0, second column is 1, etc.

1 Like

You’ll have to show us your code for those steps.

@nxr

Please show what you tried there. May be some variable you are not looping or changing as per the iteration

cheers

After downloading the file, the robot goes through the following activities:

Using Path Exists activity with the following expression:
Directory.GetFileSystemEntries((Directory.GetDirectoryRoot(Directory.GetCurrentDirectory)+"tmp/home/Downloads"), "*.svg", SearchOption.AllDirectories)(0)

Followed by Upload Files with expression:
Enumerable.Repeat(___map_PathExists_3__Resource, 1).ToList()

@nxr

May be the files are not ordered as per the downlaoded date and time

before (0) use a orderby function as below

Whateveryoualreadyhave.OrderByDescending(function(x) IO.File.GetLastWriteTime(x))(0)

1 Like

Really not sure what you’re trying to do here. I think you don’t need the Path Exists activity, it’s not doing anything.

Where did you get that Upload Files activity? I only see a Google Drive activity that uploads one file at a time (ie Upload File). Anyway, you probably just have to provide Directory.GetFiles("folderpath) to that so it can upload the files.

You’re overcomplicating things.

  • Create folder to store files
  • loop through spreadsheet
    – download file to folder you created (if your browser is just automatically putting them into the C:\Users\username\Downloads folder then just use the wait for download activity and then move the file to the folder you created)
  • in the Upload Files activity, use Directory.GetFiles to provide an array of files in the folder you created

Thanks for the suggestion, Paul!

Thing is, this was all happening in the cloud, robot opening website, robot downloading on server and then uploading on Google Drive in order for me to access files.

The solution for saving files and finding them on the server in order to allow upload was found here: Studio Web - how to download a file and upload it to OneDrive

Maybe I misunderstod your suggestion; bottom line the flow is now working flawlessly, so thanks for all your help!

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