Neo4j how to load relations from csv with attributes

101 Views Asked by At

I have been trying to load 2 csv files to create entities and relation.

This one is for the entities:

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///jobs.csv" AS row
MERGE (j:JOB {order_id: row.child_order_id})
SET j.job_name = row.child_job_name,
            j.job_owner = row.child_job_owner,
            j.group_name = row.child_group_name,
            j.order_time = row.child_order_time,
            j.start_time = row.child_start_time,
            j.end_time = row.child_end_time,
            j.elasped_min = row.elasped_min;

This one is for the relations:

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///child_father.csv" AS row
MATCH (c:JOB {order_id: row.child_order_id})
MATCH (f:JOB {order_id: row.father_order_id})
MERGE (c)-[d:DEPENDS_ON]->(f)
ON CREATE SET d.elapsed_min = row.elasped_min;

I wanted to load the relations and make them had an attribute elapsed_min, but they ended up not having it.

0

There are 0 best solutions below