How to fetch specific values in excel file using LINQ?

Hello please help me in this scenario
Input file is given
InputData.xlsx (11.9 KB)

image
The process should get looped

After fetching it should store in array values. ID101 = Array{Child values)

Thankyou
soundarya

Hi @Soundarya_Guduri1

Please try this

Syntax
Array of string = DT1.AsEnumerable.SkipWhile(Function(x) x(“Parent”).ToString<>“ID115”).TakeWhile(Function(x) x(“Child”).ToString<>“ID101”).Where(Function(x) not String.IsNullOrEmpty(x(“Parent”).ToString) or String.IsNullOrEmpty(x(“Parent”).ToString)).Select(Function(x) x(“Child”).ToString).toarray

it helps!

Thankyou @Dinesh_Guptil

I will check it let you know

Hi
Just now checked but not optimistic so
Can you give LINQ syntax for only ID101

Hi @Soundarya_Guduri1


It Helps!

Hi @Soundarya_Guduri1

Check This is one for ID101
Syntax : DT1.AsEnumerable.SkipWhile(Function(x) x(“Parent”).ToString<>“ID101”).TakeWhile(Function(x) x(“Parent”).ToString<>“ID115”).Where(Function(x) not String.IsNullOrEmpty(x(“Parent”).ToString) or String.IsNullOrEmpty(x(“Parent”).ToString)).Select(Function(x) x(“Child”).ToString).toarray

It Helps!

Hi,

Can you try the following sample?

dict = dt.AsEnumerable.Select(Function(r,i) Tuple.Create(dt.AsEnumerable.Where(Function(r2,j) j<=i AndAlso r2(0).ToString<>"").Last() ,r(1).ToString)).GroupBy(Function(t) t.Item1.Item(0).ToString).ToDictionary(Function(g) g.Key,Function(g) g.Select(Function(t) t.Item2).ToArray)

Sample20230922-4L.zip (10.6 KB)

Regards,

can you develop for this input

@Soundarya_Guduri1

check this

It Helps

suppose i need only id-124 child items

DT1.AsEnumerable.SkipWhile(Function(x) x(“Parent”).ToString<>“doc id-124”).TakeWhile(Function(x) x(“Child”).ToString<>“doc id-132”).Where(Function(x) not String.IsNullOrEmpty(x(“Parent”).ToString) or String.IsNullOrEmpty(x(“Parent”).ToString)).Select(Function(x) x(“Child”).ToString).toarray

If i executed this query i am getting child items from Department_29 to dummy2(1).ppt

Thankyou

@Soundarya_Guduri1

Use This

DT1.AsEnumerable.SkipWhile(Function(x) x(“Parent”).ToString<>“doc-id-124”).TakeWhile(Function(x) x(“Parent”).ToString<>“doc-id-132”).Where(Function(x) not String.IsNullOrEmpty(x(“Parent”).ToString) or String.IsNullOrEmpty(x(“Parent”).ToString)).Select(Function(x) x(“Child”).ToString).toarray

@Soundarya_Guduri1


That Column name should be parent

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