从csv导入时创建Neo4j关系

时间:2018-03-10 09:27:25

标签: neo4j cypher

我是Neo4j的新手。我有包含以下格式的数据的csv文件:

"from","to","amount","count"  
"Lenin","George","10000","1"  
"Mike","Suriya","4000","3"  
"Mike","Norman","10000","1"  
"George","Lenin","4000","1"  

现在,我想用关系导入这个csv,这样我就可以获得像列宁和乔治那样的循环重定向图。我该怎么做?

1 个答案:

答案 0 :(得分:0)

您可以使用

LOAD CSV WITH HEADERS FROM "file:///csv.csv" as row
MERGE (n:Person{name:row.from})
MERGE (m:Person{name:row.to})
MERGE (n)-[r:RELATIONSHIP]->(m)
ON CREATE SET r.amount = row.amount,
              r.count = row.count

检查https://neo4j.com/developer/guide-import-csv/以获取更多信息