Hi,
I have a python script which generates list of json like following:
[{'Identifier': 'XYZ', 'Description': '', 'Type': 'ABC', 'SubType': '', 'Date': '', 'Mnemonic': '', 'Notes': ''}]
I want to write a cypher query to create a node using this json data as the node properties and 'Type' field as the node label.
How can i proceed for this without using any apoc function calls.
Hi @cobra.
Thanks you for the response but it didn't solve my problem. The problem is that the dictionary keys are inside single quotes however, if we remove the quotes from the keys of dictionary like: instead of 'Identifier', 'Description'...,if we use Identifier:'XYZ', Description: '' the query is working fine.
Hi @cobra,
Actually, i'm not loading data. The data is with me in the form of list of dictionaries. I need to read that list of dictionaries and write a cypher query to CREATE nodes using these dictionaries. Like for a list containing only one dictionary: [{'Identifier': 'XYZ', 'Description': '', 'Type': 'ABC', 'SubType': '', 'Date': '', 'Mnemonic': '', 'Notes': ''}], one node should be created with all the dictionary data as node property. I hope it is clear.
I tried,
WITH {Identifier: 'XYZ', Description: '', Type: 'ABC'} as value
UNWIND value as node
CREATE(m) SET m=node.
This is working fine but without quotes. Whereas, below one doesn't work:
WITH {'Identifier': 'XYZ', 'Description': '', 'Type': 'ABC'} as value
UNWIND value as node
CREATE(m) SET m=node
You can try using py2neo if you have so many labels and properties like:
store json list in data
from py2neo import Garph,Node
labels=["Sample"]
properties = data[0]
print(Node(*labels,**properties))
a=Node(*labels,**properties)
tx=graph.begin()
graph.create(a)
tx.commit()
You can write for loop for no.of different Nodes creation.