Building a pathway of nodes from csv file

Sure, you can do exactly what you suggested. I just would not split the value twice, but perform it a 'with', so it can be used after.

load csv with headers from "file:///Book1.csv" as row
merge(rootNode:Node{name:row.node})
with rootNode, row
unwind split(row.element,";") as x
with rootNode, split(x,'-') as elementAttributes
merge(element:Node{name:elementAttributes[0], value:elementAttributes[1]})
with rootNode, collect(element) as elements
with [rootNode] + elements as nodesToLink
unwind range(0, size(nodesToLink)-2) as index
with nodesToLink[index] as a, nodesToLink[index+1] as b
merge(a)-[:LINKED_TO]->(b)

Screen Shot 2023-02-22 at 5.22.39 PM

1 Like