共计 626 个字符,预计需要花费 2 分钟才能阅读完成。
import csv
from py2neo import Graph, Node, Relationship, NodeMatcher
def aa():
g = Graph('http://localhost:7474', user='neo4j', password='HTL123123',name='neo4j') # 连贯 neo4j,将 'xxx' 别离改为你的用户名和明码
# g.delete_all() # 革除 neo4j 中原有的结点等所有信息
with open('C:/Users/h1531/Desktop/tea.csv', 'r', encoding='gbk') as f:
reader = csv.reader(f)
for item in reader:
# if reader.line_num==1:
# continue
print("以后行数:", reader.line_num, "以后内容:", item)
start_node = Node("供应商名称", name=item[0])
end_node = Node("属性值", value=item[2])
relation = Relationship(start_node, item[1], end_node)
g.merge(start_node, "供应商名称", "name")
g.merge(end_node, "属性值", "value")
g.merge(relation, "产品总数量", "属性")
if __name__ == '__main__':
aa()
正文完