Read file names from excel row by row and search for the file in the specified folder and upload the file in the application if exists

Hello Everyone,

Please help me in getting my requirement done in UiPath, my requirement is as follows,

  1. Have to read an excel, which contains all the Filenames under one column.
  2. Read each Filename from the excel and search for the file at one specified folder location (For Example: C:\Files) folder.
  3. If file doesn’t exist then fetch the next Filename from the excel sheet.
  4. If file exists at the specified location then open one application and navigate to some specific location and upload this file.
    5, Repeat this process for all the Filenames in the excel sheet.

Hope you got the requirement.

Please throw your great thoughts on this. Thanks in advance.

Hi @rajas

Please see answers below

  1. Use Read Range Activity and create a dataTable and use it as your output.
  1. Use for each row activity on the output dataTable, inside the do section use the Path Exists activity with the following syntax “C:\Files”+row(columnName), create a boolean and place it as the output of this activity.
  1. use an If activity with the Boolean as the expression, in the Then section place the process to open your application and upload the file, in the else section just don’t place anything.

Hope it helps,
Regards,
Reda

1 Like

Hi @rajas
You may use the below example as a support, where “dt” is the output of “Read Range”, “fileName” is the output of “Get row item”, and "fileExists’ is the output of “Path exists”.
In the sequence for the column “Then” in “If” add the activity “Open application” and the activities you want to perform to attach the file. Please note that in this case the application will be opened each time for each file, and you may need to think how and when to close it. This may be solved e.g. by rewriting the flow to open the application IF ANY file exists. Please let me know if this workflow below solves your matter :slight_smile:

1 Like

Hi could you please share the XAML File?

Hi @rahul_gola
Will this help you? In your excel, the file names would be quoted in the column Aexample.xlsx (8.4 KB) check file paths from excel.xaml (10.2 KB)

1 Like

hi thank you for sharing the xaml and example… is there a way to read the files one by one mentioned in column a(all are excel files) and save the desired cell value in output file,

may i know what dependencies are you using because i am getting this error…

Got it i have install the dependencies, uipath was got updated and somehow i have lost all the dependencies.

and now i have the problem with opening excel files one by one get the cell value and print it in excel output

Hi, I understand that instead of pdf files like in my example, you have excel files listed in that “main” excel file, where you would like to get the value of some specific cell for each of them. You can achieve it by many ways - e.g. by “Read cell” activity from the “Workbook” scope, where you need to specify which cell it is - e.g. A1. For that, you don’t even need to open these files :slight_smile: Another ways are for example via “Read Cell” from the “Excel” scope or “Get Row Item” from the “DataTable” scope, but these require some extra action - in the last case you would need to first convert each excel to a data table - e.g. by an output of “Read range” activity from the “Excel” scope

1 Like

Thank you very much for the support. The above works well :slight_smile:
it would be very helpful if you could share the xaml file for reference. i am very new to the tool uipath but it so much helpful here to get learning boost.

Thank you so much once again. PAD :slight_smile:

That is the very same xaml as before - I’ve just added these two activities as shown in the picture:Read cell (settings are shown on the right) and Write line in the scope of If fileExists :slight_smile:

Perfect thank you very much :slight_smile:

1 Like

could you please help me with one more thing. i want to take sheet name dynamically from all the excel files exists in the directory.

Hi @rahul_gola, for that you can create a variable for the “Workbook” in your Excel Application Scope (for example “wb”) and use it to get your sheet names via wb.GetSheets - will the following threads help you? :slight_smile: Copy Excel File with Dynamic Sheet Name or How to fetch sheet name of excel file in variable

1 Like

hey sorry for late reply.
Thank you so much for the support.

np :slight_smile:

1 Like