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.

Adding properties to relationship while load data using LOAD CSV option

How to add properties to relationship while load data using LOAD CSV option?

1 ACCEPTED SOLUTION

If you use the test.csv from apoc.load.csv docs:

name,age,beverage
Selma,9,Soda
Rana,12,Tea;Milk
Selina,19,Cola

Load age into a relationship between person and beverage:

CALL apoc.load.csv('test.csv')
YIELD lineNo, map
MERGE (p:Person {name: map.name})
MERGE (b:Beverage {name: map.beverage})
MERGE (p)<-[:DRANK_BY {age: map.age}]-(b)

View solution in original post

4 REPLIES 4

jggomez
Graph Voyager

Hi, you should have a csv with relationships and properties.

https://neo4j.com/docs/getting-started/current/cypher-intro/load-csv/

Thanks iggomez for the source..

If you use the test.csv from apoc.load.csv docs:

name,age,beverage
Selma,9,Soda
Rana,12,Tea;Milk
Selina,19,Cola

Load age into a relationship between person and beverage:

CALL apoc.load.csv('test.csv')
YIELD lineNo, map
MERGE (p:Person {name: map.name})
MERGE (b:Beverage {name: map.beverage})
MERGE (p)<-[:DRANK_BY {age: map.age}]-(b)

Thanks tony.. it helped