How to convert text file data into excel

Hi ,

I have data in txt file in the form of
Employee Name: xxxx
Desgination:xxx
Country:xxx

data should be in excel in the form of
Employee Name Desgination Country
XXX xxxxx xxxxx

Can you anyone?

Hii @Meda_SivaPrasad ,
Please check this workflow.

TxtToExcel.zip (1.9 KB)

TextToExcel.txt (71 Bytes)

Hope this might help you
Cheers,

1 Like

@Meda_SivaPrasad

Welcome to the community…

  1. Read the text file into string str using read text file activity
  2. Use build datatable activity and add 3 columns as required with required names
  3. Use tadd datarow activity with arrayrow as str.Split({"Employee Name:","Designation:","Country:"},StringSplitOptions.RemoveEmptyEntries).ToArray()

Hope this helps

cheers

Quick Dirty Compact Approach:

1 Like

Hi @Meda_SivaPrasad ,

As an alternate, you could also check with the below Steps :

  1. Create an Output Datatable with the required columns using Build Datatable activity, the Datatable let be named as OutputDT.

  2. Next, Use Matches Activity with the input as the data from the text file and the Regex Expression as the below, get the Output to a variable, say mc :

Employee Name:(.*)\s+Designation:(.*)\s+Country:(.*)
  1. Next, we can use this output to populate the created datatable using the below Linq Expression :
OutputDT = mc.Cast(Of Match).Select(Function(x)OutputDT.Rows.Add(x.Groups(1).ToString,x.Groups(2).ToString,x.Groups(3).ToString)).CopyToDatatable

Visuals :

image

1 Like

Thank you It’s working.

Please mark it as solution if its working :slightly_smiling_face:

Thank you.

@ppr

Good to see dirty…:joy::joy: