Reputation: 129
It has been a while (2 years) since that same question was asked. Back then, creating nodes or relationships with parameterized labels was not supported in Cypher. Is it better supported today?
What I want to accomplish is to simply to create nodes in Neo4J using Cypher, from a CSV file, providing that the file contains 2 columns, one for node type and one for node name:
LOAD CSV WITH HEADERS FROM 'https://xyz/nodes.csv' AS line
WITH line.type as label
CREATE (:EVAL(label) { name: line.name })
Here is the link to the same question, asked 2 years ago.
Upvotes: 1
Views: 515
Reputation: 20185
With pure Cypher you can't, but nowadays everybody use the APOC library with the apoc.create.node
procedure :
LOAD CSV WITH HEADERS FROM 'https://xyz/nodes.csv' AS line
CALL apoc.create.node(['EVAL', line.type], {name: line.name})
YIELD node
RETURN node
Upvotes: 2