How to insert the downloaded CSV file to an existing Excel file

To whom it may concern

I’d like to know how put the CSV file downloaded from the cloud and put to an existing Excel file.

· When I download a CSV file from Chrome, the downloaded file appears at the bottom of the browser. I have no problem opening the CSV file by clicking the tile of the file.

· Some of the CSV files have such names as below.

Example) ABC123XYZ.csv ABC456XYZ.csv etc.

· The sheet names of the CSV file are the same as the file name.

· Excel file name is unique. (similar to CSV example)

· There are multiple sheets in the Excel files, and the sheet name I’d like to paste to is “AAA”.

Since I have just stared using UiPath, I’m not familiar to the system yet. I would appreciate it if you could help me.

Thank you.

HI @YC75

Sorry for the late response… You can achieve this by following few simple steps. once the file is downloaded, and since you should provide the name to open the file we can do something like this.

We can use the assign activity to get the list of excel files in your download folder. Similar to below.
image

FolderPath is actually a variable that I have created to hold the download folder address

This will give you an output of a String Array that contains a list of files that has the extension .csv irrespective of the name it holds.

Now, in order to read the csv file, you can use a Read CSV activity

Since you have an array of files now, you can use a For Each loop to handle this

The excel variable (mentioned in my screenshot) actually holds the file name. So use an assign activity just before the read csv with the shown command to extract the file name from the path.

You don’t need to worry about the sheet name with CSV files. That is only required for xls or xlsx files.

This will get your job done…

You can do the same with Excel… to write to excel, you can use the Write range activity. Give the file path, then give “AAA” for the sheet name.

That’s about writing data. Now, if it’s okay to overwrite data in the sheet AAA that’s fine. If you want to append the new data to the existing data, you will need to change to Range property of the write range activity dynamically…

Let me know if anything is not clear… it would be glad to help… :slight_smile:

Thank you very much for your replay and I’m sorry for the late replay.

I didn’t know such a way.
It’s really useful for me to know that.

I will try the way you told me immediately.

If there is something that I do not understand, let me ask questions again.

Thank you for your kindness.

Regards,

2 Likes

No worries… we are here to help everyone to learn UiPath… It is always required to have such support and its a pleasure to help :slight_smile:

Feel free to ask anything anytime…

Sir,

can I learn from you. How to write csv files into a single excel sheet dynamically (not overwriting it)?

Regards,
Victor