Sepeate file by filter column in Excel? (use linq)

I want to separate file By column Reason Of BC as below.

image

I want to write data BA No. in another file excel.

Example : Create file excel for reason of BC 106CC
remark If column Total Mobile >=1000 separate file to new file.

From data above can write new excel = 4 file

  • file 1 = BA No. Reason of BC = 106:CC & Total Mobile <1000
  • file 2 = BA No. Reason of BC = 106:CC & Total Mobile >= 1000
  • file 3 = BA No. Reason of BC = 99:Header & Total Mobile < 1000
  • file 4 = BA No. Reason of BC = 99:Header & Total Mobile >= 1000

File excel (input)

SepFile100.xlsx (10.3 KB)

output :
SpiltFile.zip (22.4 KB)

Please guide me about it.

@Maria99

This can be done by using Filter Datatable also
You can give conditions and output to a datatable that you can write to excel

Hope this may help you

Thanks

This can be simply done using Filter Datatable

@Srini84 How to filter and write file separate excel?

@Maria99

Try with this also
Use Assign activity

Dt = Dt.Select("[Reason Of BC] = ‘106:CC’ And Convert([Total Mobile]),System.int32 < 1000”).CopyToDataTable

Hope this may help you

@Maria99

Also, as alternative

DataTableVar = (From d In DataTableVar.AsEnumerable
Where Reason of BC = “106:CC” And CInt(Total Mobile) < 1000
Select d).CopyToDataTable

Thanks

@Srini84 If I have more reason of BC
Example : 106CC , 99Header ,…
image

How to edit your linq (Don’t fix details in column Reason OF BC ?

@Maria99 - Looks like you have already created one post on the same query right? If yes, please do not create multiple post on the same topic…

https://forum.uipath.com/t/write-textfile-from-excel/343864

1 Like

Any​ idea for​ this​ case?

@Maria99,
You have opened 3 topics for the very same question. This will not help you get answers and help faster as it’s being caught by our spam bot. All topics will be merged into one. Please do not do this next time.

@Maria99

Create an array of string with your Reasons

String[]Variable = {“106:CC”,“99:Header”}

Use For Each activity Change the Type Arguments to String , then your linq function will be like

DataTableVar = (From d In DataTableVar.AsEnumerable
Where Reason of BC = Item.ToString And CInt(Total Mobile) < 1000
Select d).CopyToDataTable

Hope this may help you

Thanks

1 Like

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