Appending using a for each loop

How do you take all the files in one folder and append them to a master file in another folder? I need to read them from A7 b/c that’s where the data starts for each one. Because of this, my read range activity isnt working. I cant really give an Outputfile name b/c there’s like 20 files. (Files= Directory.GetFiles(Outputfolder))

check the following

the variable Files is an array of all filepaths which are to read
read range will use the current looped excel - variable file
write range / append range will use the excel full file path where all files are to merge

Otherwise debug and race the flow for more details in your case and implementation

So do i just change the read range to file instead?

@Laura2

In the read range pass file so that in each loop it would read a different file

But might fail in parallel as two streams might access excel file at same time.check on the same

Cheers

Yes it gives an error because the destination file is already being used. im not sure how to do it.

Hi @Laura2
Instead of parallel for each action, use normal for each action.

Regards,
Kaviyarasu N

@Laura2

Use a normal for loop Instead of parallel

Thank you I do need to change that.

I’m still having a problem with how to do a read range on multiple files in order to append each one to a master file. The files are actual dates such as

12.01.2022 3130,
12.01.2022 3131,
12.02.2022 3130,
12.02.2022 3131

@Laura2

Directory.getfiles("folderpath","*.xls*") will give you array of all files…

Then inside loop use the currentitem as filepath in read range and read the data… then use append range activity as the next step in loop to the target file

Cheers

This worked. Thank you.

1 Like

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