Today I have a challenge to carry out a roundtrip control and I would like your help.
I’ll give you an example of what I need to do.
Example:
I have 2 routes, the outbound and the return route.
The departure being:
RT827 - FMH-FRC-01 SOC-SP5
Being the return:
RT831 - SOC-SP5 HUB-FRC-01
Therefore, this route is a roundtrip FMH-FRC-01|SOC-SP5|HUB-FRC-01.
I would like the flow to return only those that fit this round trip pattern, and also return the IDs in 2 columns, one column for the first route and the second for the second route.
Point of attention, routes do not necessarily follow the FMH-SOC-HUB format, SOC-SOC-SOC may exist.
Example
SOC-SP2 - SOC-SP6
SOC-SP6 - SOC-SP2
I will leave the file attached, I count on your collaboration
Hello @Gabriel2020 ,
I have tried to solve your problem, but I am not sure whether it is what you expect.
This is the output I am getting is attached below
I have tried not use any regex or string manipulation stuff and just used basic cell splitter and row filter nodes. I have attached the workflow as well.
Reiterating what @ArjenEX said… I don’t think you fully answered that point and your example didn’t really help me either
So you’ve given us a new piece of information that the FMH, FRC and SOC prefix apparently isn’t part of the location. So questions:
Is the location always the part that follows FMH- FRC- or SOC-
Are there any other possible prefixes?
If (origin) HUB-FRC-01 is the same place as (destination) FMH-FRC-01 because both places are FRC-01 then why isn’t (origin) FMH-FRC-01 the same place as (destination) FMH-FRC-01 (as per @ArjenEX 's comment)
I think the above questions would be answered by your telling us a bit more about what the codes built into your data mean. You obviously know your data, but please keep in mind that to us it is all just codes with no meaning, so please can you give more detail.
This task is a little complicated, so I’m sorry for not making it clear.
In the logistics we practice today in the company where I work, we separate the packages, which is why FMH and HUB are the same address but separated by acronyms.
FMH means that the packages came from the supplier, and HUB that they will be delivered to the recipient.
By removing the acronyms, it is possible to arrive at a common sense, such as FRC-01 | SP5 and SP5 | FRC-01. What I need is exactly this to understand what goes back and forth.
Another Example SP5 | SP2 and SP2 | SP5 is the same thing, it just changes the origin but it is a round trip, which is what I need to do and return in the model shown above.
My director wants to understand how many routes we currently have, and how many are roundtrips, which is this “back and forth” model.
If you have SOC-SP5 | SOC-SP2 and SOC-SP2 | SOC-SP5 on two routes, how do you know if the round trip is SP5 | SP2 | SP5
or SP2 | SP5 | SP2
or are they both considered to be the same thing?
Is a round trip only ever from Place A to Place B and then back to Place A?
i.e. You aren’t trying to find more complex round trips involving more than two routes at a time?
Another question… you have multiple trips because this is a journey history. Are you wanting just the total distinct routes, or the total number of trips on each those routes (so if the same round trip occurs 10 times, you want it listed once or 10 times?)
In the last file I sent, I removed duplicates and unnecessary columns. Only Origin x destination and route ID remained.
I think it’s quite difficult to explain, but it’s a simple task.
I have route A with origin (X) and destination (Y).
And I have route B with origin ( Y ) and destination ( X ).
What I want to know is exactly this.
X and Y or Y and X is the same thing.
Therefore, the route is X | Y | X. And with that done I can apply the model I sent above, where I have what formed (X | Y | X) the ID (A) and the route ID (B)
At the end the data is split into two tables. The upper table contains the round trips and the lower table contains the one-way trips.
I prioritised “origins” so a round trip is
FMH-SOC-HUB rather than HUB-SOC-FMH
or
HUB-SOC-HUB rather than SOC-HUB-SOC
This priority order is set in the Table Creator with the Value Lookup, so can be easily adjusted if necessary
Sorry @Gabriel2020 , for some reason i thought you were on KNIME 5.2. When i get a chance, I’ll import it into 4.7 and replace those nodes with alternatives.
Btw @Gabriel2020 , I’d recommend taking a full backup of your workspace folders before actively opening all your workflows in 5.2.
If you save in 5.2, it can replace some nodes such as column rename, and several others, making it incompatible if you ever need to go back to 4.7 to check something.