cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site maintenance this Wednesday, February 1. Disruptions expected as we migrate the forums.

Unique Nodes loaded from CSV file

I have the following simple Cypher script:

LOAD CSV WITH HEADERS FROM "file:///test.csv" AS row FIELDTERMINATOR ';'
merge (n:Subject {code: row.NodeA})
merge (m:Object {code: row.NodeB})
merge (r:Relation {code: row.Relation})
MERGE (n)-[:TO]->(r)
merge (r)-[:TO]->(m)

with the following test.csv:

IDNodeARelationNodeB 
1AM 4.0includesSystemic leadership
2AM 4.0 is based on Agile Mindset

My assuption is that the Cypher script should generate unique Nodes n, so only one Node n with Code = NodeA ={AM 4.0} should be generated.

But this is not the case. Also the usage of CONSTRAINT for Code doen't help.

What goes wrong?

Thank you very much for your help!!

1 ACCEPTED SOLUTION

busymo16
Ninja
Ninja

Hi @Alfred_Oswald, MERGE creates the node only if it is not existing and in this case it has to only create one node with the label Subject and two nodes with the label [Systematic leadership, Agile Mindset]. The only problem might be coming from you file, if the column NodeA has some extra spaces then it is considered as a different string. From what you have shown here, this might be the only idea that I have. 

If you can share more, like some logs of what is happening there, I might be able to help you more. 

View solution in original post

2 REPLIES 2

busymo16
Ninja
Ninja

Hi @Alfred_Oswald, MERGE creates the node only if it is not existing and in this case it has to only create one node with the label Subject and two nodes with the label [Systematic leadership, Agile Mindset]. The only problem might be coming from you file, if the column NodeA has some extra spaces then it is considered as a different string. From what you have shown here, this might be the only idea that I have. 

If you can share more, like some logs of what is happening there, I might be able to help you more. 

Dear ninja busymo16, your hint is the solution! Thank you very much!!!