Retrieve the same item from multiple data branch

Dear Community,

I need a little help to manage more branch in a data Tree.

for this case, I have lists with Date Time for each data Branch, but I need to see if among all the branches there are the exact minutage and know which Branch has the same minutage. Any suggests?

I attached the example:
DateTime.gh (192.2 KB)

Thanks in advance

Hi, maybe like this?

Hello Toto, thanks for the answer.

Maybe not, this is a variant that I had already tried, why so I need to enter manually the date to search. I had something to automate the whole thing.

Thanks

Do you want to search for branches that contain exactly the same Date Time values ?
Or to check which Date Time values exist in every branch ?

This could be a source of inspiration Find similar and different list points

1 Like

Hello John,

please find attached if the results suit you. A bit heavy challenge in terms of computing time I have to say.

Best regards,

Pavel
DateTime_PSL.gh (194.6 KB)

1 Like

That’s an elementary LINQ task (real-time no matter how big the DataSet is: this means a few milliseconds for doing the List and extract any type of stuff via some query - you don’t even need PLINQ for that [P for parallel]).

  1. Step 1. Define a custom type class and sample your data in a List of that type. The 5 minute code for that is :

  1. Step 2. Then you just need a LINQ line of code per query (any imaginable search: like find days that are in some Time Interval, find Months that have this time Interval, find cats, find dogs … blah, blah). Since the class Properties include the Path and the Index … well … you can guess that the pos in the DataTree is the easiest thing to retrieve

So if you are interested for that type of solution I could add some Lines more for some demo queries (results in real-time etc).The classic way to do it is like that (where the searchMin/Max define the search Interval).

Of course you can run any imaginable nested query as well.

BTW: For a different DateTime input format you just need to change the mask:

1 Like

You weren’t kidding, takes 9 minutes 40 seconds on my old computer :roll_eyes:

I expanded on what @PeterFotiadis provided and came up with this.

DateTime_re_linq.gh (196.8 KB)

Sorts the input data, groups it by days, and shows the path and index from the source data → takes less than 0.5 seconds.

I’m still a beginner at C# scripting, and welcome any suggestions.

-Kevin

1 Like

dear @Pavel2, dear @kev.r , thanks for the help, very very appreciate. This is almost the solution.

@kev.r It would be perfect, to split each shared Date time into a separate branch, like in pavel’s script, but have it sort in time order, like in your script. If it’s not possible, it’s still not a great problem.

But it would be much easier for me to read the results, if the index number is not present at the end of each item, but only the path in the {x}
00

Thanks to all, to help me
Best Regards, J-Rob

Er … there’s some that I can think … but I’m sure that you know what I mean.

Anyway after sorting the chaos … do the following:

  1. Provide a data validation pre check.
  2. Provide query options (i.e. do this or that etc etc) and primary/secondary/… search Intervals (for multi nested queries as is the norm in real-life). If searchMin iis > than searchMax use a Swap Method. Uae public vars for the search in order to avoid calling locomotive long Methods.
  3. Replace any native component with code.
  4. Practice GroupBy and THEN OrderBy (in a flat or nested LINQ - multi nested queries is the essence of data mining in Engineering).
  5. Exploit PlanB (PLINQ) - but don’t expect big things.
  6. Exploit PlanC: a thread safe // approach.

BTW: Building the DT List takes about 15 to 70 ms (the latter using an ancient I5 [ on purpose]) … so 500 more for the LINQ part is way toooooo much (*). For that type of queries (i.e. not calling some heavy Method(s)) and for ~100K values one should expect 100 ms in total.

(*) for instance this primitive flat LINQ thingy requires 10 ms more:

2 Likes

Done.

DateTime_re_linq_2.gh (194.2 KB)

@PeterFotiadis thanks for the suggestions, I will investigate later when I have time.

-Kevin

2 Likes

Some tips:


awesome…many thanks @kev.r

I wish you happy holidays
J-Rob