Add a node to the End of a Node Chain

Please if someone could help.. I think that this is pretty easy but, I don't seem to have a good (well any) solution. I want to build a chain (a thread) of Event nodes. Initially these Events will be loaded from a CSV file something like this;

ProcessId,Events,LoadDateTime
process01, event1:event1Type;event2:event2Type;event3:event3Type,5-10-2025

Comas separate each column. The second column is a multi field with elements separted by a semi-colon (;). each Event has a Name and a Type seperated by a full colon (:).

each even in the Second column (Events) can do a split(event,":")[0], or [1]...
the Event variable will come from a forEach (_ In Case When (row. Events is not null) Then [1] Else[] End | type statement, if that makes sense..

but inside my forEach chunk of code, how do I create the first Event and then remember the last one I create to the next Even can be tied to it? should be easy but.. sigh..

if you could help, that would be really great..

Any Ideas Guys.. Is there a good way in regular Cypher or Python to pull this off or.. should I build this logic in something like Java and just execute it through a transaction. Any good tricks come to mind?

@raylukas97

I've done similar but slightly different. For example a single node with N relationships to another node and the relationship has a timestamp or increment property to allow one to figure out the order. For example a single node with label :Conversation and it has N relationship pointed to nodes named :Response. each relationship pointing to a :Response node has a relationship which describes the order of Responses

You want something like this:

import csv
from neo4j import GraphDatabase

# Neo4j connection setup
uri = "bolt://localhost:7687"
username = "neo4j"
password = "your_password"

driver = GraphDatabase.driver(uri, auth=(username, password))

def process_csv_and_create_chain(file_path):
    with open(file_path, newline='') as csvfile:
        reader = csv.reader(csvfile)

        for row in reader:
            process_name = row[0]
            event_chain = row[1]
            date = row[2]  # Optional use

            events = event_chain.split(';')
            event_nodes = []

            # Create Process node
            with driver.session() as session:
                session.run("MERGE (p:Process {name: $name})", name=process_name)

                prev_event_id = None

                for i, event_pair in enumerate(events):
                    event_name, event_type = event_pair.split(':')

                    event_id = f"{process_name}_event{i}"  # here you need your unique identifier

                    # Create event node
                    session.run("""
                        MERGE (e:Event {id: $id})
                        SET e.name = $name, e.type = $type
                    """, id=event_id, name=event_name, type=event_type)

                    # Connect event to process (if desired)
                    session.run("""
                        MATCH (p:Process {name: $process_name}), (e:Event {id: $event_id})
                        MERGE (p)-[:HAS_EVENT]->(e)
                    """, process_name=process_name, event_id=event_id)

                    # Create chain with previous
                    if prev_event_id:
                        session.run("""
                            MATCH (prev:Event {id: $prev_id}), (curr:Event {id: $curr_id})
                            MERGE (curr)-[:PREVIOUS]->(prev)
                        """, prev_id=prev_event_id, curr_id=event_id)

                    prev_event_id = event_id

# Example usage
process_csv_and_create_chain("processes.csv")

Right..., That is what I thought, so, there is no good way to do this inside of my Cypher Load from Csv file script.. need to create a chunk of code in my server layer.. which is fine.. so lets say I am only given a Process and a new Event node to be added at the end of the chain... . Is there a good way to get to the last node in the Process's Event chain..
Something like a path query maybe?
Lets say we get interactively a Process Name and the Event:EventType as two params passed into my code.. So if I have/create a path, how do I get to the last Event in that path since new Events can be generated dynamically.. if you see what I am asking..
You dont have to write the code, which is Exceptionally Kind of You.. I dont want to suck down your time I just need a bit of help..
Just need to know the Cypher Trick.. match the process node, get its first Even node and something like ProcessEventNode -[:xxx*]->(lastEvenNode) then create a new Event Node with a cypher, then do create lastEvenNode-[:xxx]->(newEventNode). something like this guys?

Hi Josh and Crew.. I use to be a pretty decent neo guy but.. after some things happened.. i am.. trying to recover and writing code, etc helps me in recovering.. i am trying to help out as best i can intro new folks to Graph stuff.. over many situations, i have slowly discovered that, helping out other people has a side affect, it helps you as well. so.. my stupid questions allow me to go to into my own little universe and be happy for a little while, while i still can, and fight this health issues.. so.. thanks man for putting up with me and giving me some.. social interaction.. thanks man.. Thanks.. I dont know how to text you directly but.. if I could do something for you, i will try.. Thanks man..