How to open folder and extracts data from the file and paste it in excel

I have an excel file of column “code” and column “region” . I have to open folder then inside that one more folder .In that folder there are many text files.So i need to take value of column “region” and search it in search bar of folders .Then text file need to open .In text file there are many texts but i want to extract only code value and paste it in “code” column.These i need to do for all region values

Experts plss help!!

Hello @Tabbu,

could you please provide some more information? How the text files are structured? Could you share with us the example file or at least describe? It’s a quite simple task, but please tell us more. :slight_smile:

Best regards


The value of “region” column is text file names so we need to take the value of region and go to the folder which is folder inside folder then search for the text file in search bar then from that file i need code number extract that nd put it in “code” column

Okay, that’s more clear now. Do you have any coding experience? In UiPath?

Not much i m beginner

I’d suggest you to try out some courses in UiPath Academy. UiPath Foundation course for example. You’ll get to know how to do simple tasks in no time. :slight_smile:

Can u plss help me in that question i know activities and how to work with them .I can understand whatever you will explain

I know how to open files but after that i need help like taking code value from text file nd put it in excel file

Okay, how the text file is structured? Can you send us one for example?

You don’t actually open the files. You use activities to read them in. This would be covered in the training you should take.

hi @Tabbu

Attached the file. hope it meets your logic.

Thanks, (9.0 KB)

If there are lots of text and i want only a particular text then what to provide in read text file activity?l

Hi @Tabbu

You can use regex and extract the required code from the text file or share some test file.


In text file at sixth line i have
Code. 4788

I want to fetch 4788 nd paste it in excel

Could you please attach test text file…then only we can check the regex options or some string manipulations

and also Is your all text file contains code like this “Code. Codenumber(4788)”


Here i want only code number in my excel column. And in evry text file code number is different

Hi @Tabbu

Thanks. Attached the file with your test text file. hope it solves your query.

Thanks, (10.2 KB)

Can you explain what FileCollection(0) do in read text file. Becoz i m getting error in that

“index was outside the bounds of the array”

Hi @Tabbu
just assuming the folder contains only one text file so using filecollection(0)

is your folder contains multiple text files and one text file is your regionfilename.txt?

If so, you need to find out the right file using regionname


Yess in folder i have multiple text files and i want to search only for that text files which is in region columns.
So how do i do that?

You helped me alot.pls help little more .This my project