简体   繁体   中英

Creating Neo4j relationship while importing from csv

I am new to Neo4j. I have csv file containing data in the format:

"from","to","amount","count"  
"Lenin","George","10000","1"  
"Mike","Suriya","4000","3"  
"Mike","Norman","10000","1"  
"George","Lenin","4000","1"  

Now, I would like to import this csv with relationship so that I can get graph with circular redirection like incase of Lenin and George. How would I do that?

You could use

LOAD CSV WITH HEADERS FROM "file:///csv.csv" as row
MERGE (n:Person{name:row.from})
MERGE (m:Person{name:row.to})
MERGE (n)-[r:RELATIONSHIP]->(m)
ON CREATE SET r.amount = row.amount,
              r.count = row.count

check https://neo4j.com/developer/guide-import-csv/ for more information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM