Neo4j关系没有使用Load csv添加

时间:2016-06-14 03:11:09

标签: csv neo4j py2neo

我正在尝试使用neo4j的Load csv方法。我已成功将所有节点添加到neo4j。但是当涉及到关系时,cypher语句运行没有任何错误,但它们永远不会被添加,并且在浏览器中不可见。但是可以看到节点很好。以下是我的CSV。

首先是Customer.csv,第二个是customer_send.csv

         Galactic_ID:ID(Customer),:LABEL
 1000000000036666531,Customer
 2000000000198737143,Customer
 2000000000101281958,Customer
 1000000000281474324,Customer
 1000000000073478335,Customer
 1000000000283083892,Customer
 2000000000230105092,Customer
 1000000000287320588,Customer
 1000000000020059606,Customer


    :START_ID(Customer),:END_ID(Customer),TXN_KEY,Amount,SendTime,PayTime,:TYPE
1000000000036666531,1000000000089771041,5000000000107593411,20.0,1361439,1362963.0,Customer_Send
2000000000198737143,2000000000181818203,5000000000108495674,220.0,1361434,1362369.0,Customer_Send
2000000000101281958,1000000000210500686,5000000000106488543,1000.0,1361435,1363053.0,Customer_Send
1000000000281474324,2000000000246874104,5000000000106029876,1669.0,1361424,1362506.0,Customer_Send
1000000000073478335,2000000000200242093,5000000000107872144,180.0,1361415,1362680.0,Customer_Send
1000000000283083892,2000000000258949202,5000000000107701034,156.0,1361414,1362738.0,Customer_Send
2000000000230105092,1000000000064145673,5000000000105488820,329.0,1361392,1362558.0,Customer_Send
1000000000287320588,1000000000287658165,5000000000105281335,620.0,1361391,1362365.0,Customer_Send
1000000000020059606,1000000000046608791,5000000000105081275,65.0,1361389,1363317.0,Customer_Send

以下是我的密码陈述:

In [24]: stmt6 = """USING PERIODIC COMMIT LOAD CSV FROM "file:///mnt/database/Neo/db3/import_data1/customer.csv" AS csvLine
 ....: MERGE (c:Customer {Galactic_ID:csvLine[0]})
 ....: ON CREATE SET c.Galactic_ID = csvLine[0]"""

    stmt3 = """USING PERIODIC COMMIT LOAD CSV     FROM"file:///mnt/database/Neo/db3/import_data1/customer_send.csv" AS csvLine
 Match (a:Customer {Customer:csvLine[0]}), (c:Customer {Customer:csvLine[1]})
 Merge (a)-[r:Customer_Send]->(c)
 On Create SET r.TXN_KEY = csvLine[2], r.Amount = csvLine[3], r.SendTime = csvLine[4], r.PayTime = csvLine[5]"""


graph.cypher.execute(stmt6)

graph.cypher.execute(stmt3)

创建客户节点的第一个图表stmt运行正常,节点已创建并在图表中可见。 第二个stmt运行一段时间,结束时没有任何错误,但没有创建任何关系。

1 个答案:

答案 0 :(得分:0)

尝试匹配您创建它们的属性上的节点:

Match (a:Customer {Customer:csvLine[0]}), (c:Customer {Customer:csvLine[1]})

=>

Match (a:Customer {Galactic_ID:csvLine[0]}), (c:Customer {Galactic_ID:csvLine[1]})