Copy Column (remove duplicate) and save to text file (use linq)

I have data excel about 5,000 rows.

I want Copy Column BA that Column Result (remove duplicate) and save to text file as below.

File excel as attached : input.xlsx (9.4 KB)

I want output : textfile.txt (36 Bytes)

Please guide me about it.

Hi @Maria99

Try this

Read the excel using Read Range and store in dt1

Now use the below assign actiivty

final_data = String.Join(Environment.NewLine, dt1.AsEnumerable().Where(Function(r) r(“Result”).ToString.Trim<>“D1”).Select(Function(m) m(“BA”).ToString.Trim).ToArray().Distinct)

where final_data is String datatype
Then write the final_staring to text file using write text file activity

Attaching a sample file here
sample.xaml (5.4 KB)

Mark it as solution if it helps you

Nived N

1 Like

Currently your output is different to text file
Refering to your text file, give a try on following

Assign activity
left side: arrNo | DataType: String Array
Right side:
YourDataTableVar.asEnumerable.Select(Function (x) x(“BA”).ToString.Trim).Distinct().toArray

Write text file Acitivty
File Content: String.Join(Environment.NewLine, arrNo )

1 Like

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