2
我正在使用csv批量導入py2neo(在here中描述)將rdb轉換爲neo4j。從另一個「people.csv」文件中的「電子郵件」節點是之前創建與已有節點創建關係
delivery = "Delivery.csv"
graph = Graph("http://localhost:7474/db/data/")
graph.cypher.execute("CREATE CONSTRAINT ON (delivery:Delivery) ASSERT delivery.name IS UNIQUE")
with open(delivery, 'r+') as in_file:
reader = csv.reader(in_file, delimiter=';')
next(reader, None)
batch = graph.cypher.begin()
try:
i = 0;
j = 0;
for row in reader:
if row:
name = strip(row[0])
created_by = strip(row[1])
created_on = strip(row[2])
description = strip(row[3])
delivered_to = strip(row[4])
delivered_by = strip(row[5])
barcode = strip(row[6])
query = """
merge (delivery:Delivery {name:{a}})
merge (email:Email {email:{b}})
merge (created_on:Created_On {created_on:{c}})
merge (description:Description {describe:{d}})
merge (email:Email {email:{e}})
merge (email:Email {email:{f}})
merge (barcode:Barcode {code:{g}})
##and there are some relationships##
"""
batch.append(query, {"a": delivery, "b": created_by, "c": created_on "d": description, "e": delivered_to,
"f": delivered_by, "g": barcode})
.........................................................
.........code goes as described in the hypherlink........
,並有「電子郵件」節點的唯一約束:我組織這樣的代碼。在以上幾行中,我想通過關係將「created_by」,「delivered_to」和「delivered_by」節點與之前創建的「email」節點合併。當我運行代碼時,它給出了錯誤email already declared
,並沒有從csv創建任何節點。如何組織密碼查詢以防止此錯誤?謝謝。
運行良好。謝謝 – yalcinm1