Open each CSV in a folder and extract two cells

Greetings, Community! Any help would be greatly appreciated! Thanks in advance!

I need to get a list of CSVs from a folder, for each file I need to extract the values from two of the columns (C & D), and assign them variables to be used in another process.

I will be extracting one InvoiceNumber and InvoiceAmount in the spreadsheet, using them in a process, then repeating the process with the second set of InvoiceNumber and InvoiceAmount in the same CSV file until there are no values left. Once I have done that for one CSV, I would repeat the same process with the next CSV file in the folder.

Greetings to you @Zroy21 :slight_smile:

So for your scenario… You can follow the below steps

  • Use an assign activity to get the file paths to a string array. You can get the file paths using the below query

Directory.GetFiles(“Your File Path”).

This will add the file paths of all the files in that folder to a string array.

  • Now use a For Each activity to loop through the file paths you extracted
  • Inside the loop, use a read csv activity and provide the “item” variable as the file location in read csv. Read the data onto a datatable
  • Now you can loop through the data table and get the value you need to perform your tasks. You can use a For Each Row to loop through the data table. This has to be done inside the For Each loop because we have to loop through the set of files.
1 Like