Neo4j - Insert - Data - Relation

Viewed 32

I'm begginer on neo4j

I have a data csv person list likes from on file

id,name,parentid
01, John, null,
02, Mark, 01
03, Elina, 01

I try to use apoc lib to load this data

CALL apoc.import.csv(.....) yield value
UNWIND value as v
MERGE(p:Person{id:v.id, name:v.name})

I don't know how to make the relation between them.

Can someone help me?

1 Answers

There is really a LOT of examples using LOAD CSV with Neo4j, starting from the manual : https://neo4j.com/developer/guide-import-csv/.

Really no need for APOC.

LOAD CSV WITH HEADERS FROM "file:///..." AS row
MERGE (p:Person {id: row.id}) SET p.name = row.name
WITH p, row.parent AS parent
WHERE NOT parent IS NULL AND parent <> "null"
MERGE (parent:Person {id: parent})
MERGE (p)-[:LIKES]->(parent)
Related