cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to create relationship with same label from csv file

I have two csv files , one is persons.csv and the other is relationship.csv file, they have below structure:
person.csv
name, age, sex
Bob, 25, male
Jone, 36, male
Nancy, 34, female

relationship.csv
name0, name1, relationship_weight
Bob, Jone, 20
Nancy, Bob, 30
Jone, Nancy, 100

I want to load the csv files, and create relationship with the realtionship.csv file, anyone can help me? thanks in advanced

1 ACCEPTED SOLUTION

ameyasoft
Graph Maven
Try this:

LOAD CSV WITH HEADERS FROM "file:///relationship.csv" AS row
with row

MATCH (a:Name {name: row,name0})
MATCH (b:Name {name: row.name1})
MERGE (a)-[:KNOWS {weight: toInteger(row.relationship_weight)}->(b)

View solution in original post

2 REPLIES 2

ameyasoft
Graph Maven
Try this:

LOAD CSV WITH HEADERS FROM "file:///relationship.csv" AS row
with row

MATCH (a:Name {name: row,name0})
MATCH (b:Name {name: row.name1})
MERGE (a)-[:KNOWS {weight: toInteger(row.relationship_weight)}->(b)

Thanks amyasoft a lot , it works