How to read multiple text files and extract each text file data moved to excel file

Hi,

How to read multiple text files and extract each text file data moved to excel file

Any help would be much appreciated!

Regards,

Teja

Hi

Hope the below steps would help you resolve this

  1. Use a assign activity like this to get all the files from a folder

arr_files = Directory.GetFiles(“yourfolderpath”)

Where arr_files is a variable of type array of string

  1. Then use a FOR EACH activity where pass the above array variable as input and change the type argument as string

  2. Inside the loop use a READ TEXT file activity and get the output as string

  3. Then we can use string manipulation method to get the value we need and write it back to excel with WRITE CELL activity or we can write it first to a datatable and then write that datatable to excel

To build the datatable with columns we need use BUILD DATATABLE activity

And to add data to that datatable use ADD DATA ROW ACTIVITY inside the for each activity itself by passing each value or variable like this

In add Datarow activity along property panel
Arrayrow = {variable1, variable2,…,variableN}

And datatable as dt

Cheers @tejaswi_nerella

1 Like

Hi @tejaswi_nerella

Build Datatable with Excepted headers you need to store

Use Directory.GetFiles(“Yourpath”)

Use for each to iterate the each files in folder.

Use Read Text file Activity And pass the item in read text file path input.

Use Regex to get the input text files and add datarow to make it as datatable.

Then write Range

Regards

1 Like

Hi @Palaniyappan Thank you so much for the speedy reply

I tried this method please check the below attachment

but I’m facing an error in assign activity while passing the path

image

Error: Assign: Illegal characters in path

Sequence.xaml (14.9 KB)

I think you have mentioned a file path as I could see it ends with .txt

And if you want to get only text file then mention. Like this

arr_files = Directory.GetFiles(“yourfolderpath”,”*.txt”)

Cheers @tejaswi_nerella

2 Likes

I tried the similar method Sequence.xaml (14.9 KB)

can you please check this workflow

I couldn’t access my laptop now
Can you share the screenshot of the assign activity again with that expression

@tejaswi_nerella

image

Hi @tejaswi_nerella

You need to place the build datatable before the for each activity.

Because for each item it will build new Dt with the Headers!

Regards

1 Like

Thank you @pravin_calvin

Fine

You are almost done

Pls keep the build datatable activity before all the activities

@tejaswi_nerella

1 Like

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