Reading all the files inside for each files in folder activity

I’m reading all the files (which have same pattern inside, all text files) inside the folder with For each file in folder activity now I want to read that all file individually how can I achieve this & after reading files I extracted some data with string manipulation & stored that in 3 different variables now I want to write all this data in excel file. Can you anyone please help me with this?! I have read file but in output I just able to read last file in a iteration that’s the problem.

You can use this Statement :
Directory.GetFiles(“YourFolderPath”) in an Assign Statement.

Assign this to an Array of String Variable.

Then you can Loop through the Files using a For Each

1 Like

Then i have to use for each activity only, not for each files in folder activity.

Hi @Vidhi_Patel,
please follow these steps.
1- use for each file in folder(which you are using already)
2- inside body put 3 veriables.
3- append 3 variables inside loop just after 3 Variables.
you are wriiting in excel not appending in excel that’s why you are getting last file data only

1 Like

I noted down this point i’m writing i excel not appending but before writing i have to read multiple files how can i achieve that. First i’m reading files with read text activity then extracting it in variables using assign then again writing a text file then generating datatable using generate data table then writing excel(will append excel).

@Vidhi_Patel

FilesInFolder.xaml (7.0 KB)

1 Like

Unzip_Folder_Get_Information.xaml (18.5 KB)

@Vidhi_Patel can you explain which activity you are using here.

Balareva.ZipUnzip.UnZipFile for unzipping files . i have extracted .rar files successfully in my workflow. do you want me share a whole project?

@Vidhi_Patel so after extraction
get all files through and inside loop perform all steps. where is problem?

In assigning value of variables which are using string manipulation so when i write file I’m not able to get all the account no, amount and reference no in a one text file. so i couldn’t make generate datatable and so the data of excel file .
put all this file in a folder(named challange3)then run.
Download_Settlement_Report.xaml (55.0 KB)
Main.xaml (6.6 KB)
project.json (1.7 KB)
Transaction.xlsx (7.0 KB)
Unzip_Folder_Get_Information.xaml (20.6 KB)

@Vidhi_Patel Is Data coming in variables from every file correctly?

nope,just getting value from the last file of iteration because in assign we have string variable and i want list of string or array of strings because i need same info from all the files.

@Vidhi_Patel can you give me text files.

just 2,3 sample

1 Like

Data1.txt (43 Bytes)
Data6.txt (43 Bytes)
Data11.txt (46 Bytes)

@Vidhi_Patel great. please wait.

1 Like

Remove build datatable if you found it in a workflow.

@Vidhi_Patel so you want to put all the extracted data in excel file or text file

goal is to put data into excel file but i don’t have Microsoft excel installed on my machine so create a approach like first extracting information from the file and storing in to variable now i want to write all the values of variable in the a text file and generating datatable then using datatable to write it in an excel file. let me know if you know another approach.