本文整理汇总了Python中py2neo.Node.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Node.__init__方法的具体用法?Python Node.__init__怎么用?Python Node.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py2neo.Node
的用法示例。
在下文中一共展示了Node.__init__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addMultiNodesFromJsonFile
# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import __init__ [as 别名]
def addMultiNodesFromJsonFile(neoGraph,filename):
file = open(filename)
# for all lines in the file
while 1:
line = file.readline()
if not line:
break
# replace '' with ""
respCmtJson = line.replace("'", "\"");
# ture string to json
js = simplejson.loads(respCmtJson)
# lable and key_values
labels = []
key_values = {}
#put ID into the dict
key_values['ID'] = js['ID']
keyValues = js['AVP_LIST']
# for all key_values in the AVP_LIST
for keyValue in keyValues:
# if ATTRIBUTE is category then put the value into label
if keyValue['ATTRIBUTE'] == 'entity_category':
labels = keyValue['VALUE'].split(',')
labels = tuple(labels)
#print len(labels)
else:
key_values[keyValue['ATTRIBUTE']] = keyValue['VALUE']
# labels is tuple and key_values is a dict
# use with which can create a node
node = Node()
neoGraph.create(node)
node.__init__(*labels,**key_values)
node.push()
createIndexofNode(neoGraph,node)
autoBuildRelationShip(neoGraph,node)
示例2: addNode
# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import __init__ [as 别名]
def addNode(neoGraph,jsonNode):
respCmtJson = jsonNode.replace("'", "\"");
# turn string to json
js = simplejson.loads(respCmtJson)
# lable and key_values
labels = []
key_values = {}
#put ID into the dict
key_values['ID'] = js['ID']
keyValues = js['AVP_LIST']
# for all key_values in the AVP_LIST
for keyValue in keyValues:
# if ATTRIBUTE is category then put the value into label
if keyValue['ATTRIBUTE'] == 'entity_category':
labels = keyValue['VALUE'].split(',')
labels = tuple(labels)
else:
key_values[keyValue['ATTRIBUTE']] = keyValue['VALUE']
# labels is tuple and key_values is a dict
node = Node()
neoGraph.create(node)
node.__init__(*labels,**key_values)
node.push()