How to specify relationship type in CSV?

前端 未结 3 1555
野性不改
野性不改 2021-01-21 23:38

I have a CSV file with data like:

ID,Name,Role,Project
1,James,Owner,TST
2,Ed,Assistant,TST
3,Jack,Manager,TST

and want to create people whose

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-21 23:40

    this question is old, but there is a post by Mark Needham

    that provide a great and easy solution using APOC

    as follow

    load csv with headers from "file:///people.csv" AS row
    MERGE (p1:Person {name: row.node1})
    MERGE (p2:Person {name: row.node2})
    
    WITH p1, p2, row
    CALL apoc.create.relationship(p1, row.relationship, {}, p2) YIELD rel
    
    RETURN rel
    

    note: the "YIELD rel" is essential and so for the return part

提交回复
热议问题