导入文件时,必须在database中新建一个import文件夹,实体文件和关系文件先复制到该文件夹中,才能导入。安装neo4j时会安装一个database。
导入实体:
LOAD CSV WITH HEADERS FROM “file:///person_Format.csv” AS line
MERGE (p:person{id:line.id,name:line.name,age:line.age})
显示实体:
start n = node(*)
return n
导入关系:
LOAD CSV WITH HEADERS FROM “file:///PersonRel_Format.csv” AS line
match (from:person{id:line.from_id}),(to:person{id:line.to_id})
merge (from)-[r:rel{property1:line.property1,property2:line.property2}]->(to)
显示实体和关系:
start n = node(*)
return n