赞
踩
- from py2neo import Graph, Relationship, Node
- import xlrd
-
- g = Graph("xxx", username="neo4j", password="neo4j123")
- readbook = xlrd.open_workbook(r'xxx')
-
- sheet1 = readbook.sheets()[0]
- sheet_rows = sheet1.nrows
- for i in range(sheet_rows):
- if i == 0:
- continue # 第一行是实体、关系,故跳过第一行从第二行开始遍历
- start_node = Node("Person", name=sheet1.row_values(i)[0])
- end_node = Node("Person", name=sheet1.row_values(i)[1])
- relation = Relationship(start_node, sheet1.row_values(i)[2], end_node)
- g.merge(start_node, "Person", "name")
- g.merge(end_node, "Person", "name")
- g.merge(relation, "Person", "name")
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。