Neo4j Desktop:
There is a big JSON file with entries like the one shown below.
I want to split up the entries of "src" and create nodes with each single one of the entries.
Further i want the other values to be the nodes parameters.
Input via JSON file (see below).
What is the best way to do all this stuff?
{
"transaction": "42043-134632465-3221",
"action": "Accept",
"src": "dummy593, dummy834, dummy203",
"adds": {
},
"dest": {
"name": "John Doe",
"address": "Baker Street",
"phone": "12345, 54321"
}
}
I tried to combine the functions of apoc.load.json, apoc.cyper.run and within this i used split(src, ‘,’).
I’ve gotten a security error and honestly i don’t think it would’ve worked though.
Should i use apoc.load.json
or something like with{json}
?
call apoc.load.json("file:/Users/user/.Neo4jDesktop/relate-data/dbmss/dbms-969/import/example.json") YIELD value
with value.src as src
call apoc.cypher.run("with $src as src unwind src as src create (:src {src: src})", {src: split(src, ',')}) yield value
return value
Apologies and thanks – i’m bloody new in cypher topics …
2
Answers
You can do something like this:
This is using foreach command which is similar to unwind.
Reference:
https://neo4j.com/docs/cypher-manual/current/clauses/foreach/