How to specify relationship type in CSV?

前端 未结 3 1572
野性不改
野性不改 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

    Right now you can't as this is structural information.

    Either use neo4j-import tool for that.

    Or specify it manually as you did, or use this workaround:

    load csv with headers from 'file:/../x.csv' as line 
    match (p:Project {code: line.Project}) 
    create (n:Individual {name: lineName})
    foreach (x in case line.Role when "Owner" then [1] else [] end |
      create (n)-[r:Owner]->(p)
    )
    foreach (x in case line.Role when "Assistant" then [1] else [] end |
      create (n)-[Assistant]->(p)
    )
    foreach (x in case line.Role when "Manager" then [1] else [] end |
      create (n)-[r:Manager]->(p)
    )
    

提交回复
热议问题