How to create unique nodes and relationships by csv file imported in neo4j?

后端 未结 1 1581
自闭症患者
自闭症患者 2020-12-10 07:15

Hello I was trying to import some data in csv file to neo4j in my ubuntu 12.04.

The csv file is a two column data file with no header its format is like:

         


        
相关标签:
1条回答
  • 2020-12-10 07:53

    Here's what you do.

    LOAD CSV FROM 'file:///home/nate/Downloads/file.csv' AS line
    MERGE (n:A {number : line[0]})
    WITH line, n
    MERGE (m:B {ID : line[1]})
    WITH m,n
    MERGE (n)-[:LIKES]->(m);
    

    You first create or match the :A node, then create or match the :B node, then create or match the relationship. The WITH clauses collect the results at each point in the sequence to use in the next. To find out more about WITH clauses, read Section 9.5 in the Neo4j Manual.

    0 讨论(0)
提交回复
热议问题