Reputation: 59
I saw that is possible to create relationship type dynamically according to reading csv row but when I'm trying to create a node type it says Invalid input '[': expectedd whitespace or label name
sample:
csv
Type name Person Gerard Person Alice
using periodic commit load csv from... as row
merge (node:row[1] {name: row[2]})
Thanks in advance
Upvotes: 3
Views: 1918
Reputation: 4679
You can use the apoc.merge.node
procedure:
LOAD CSV FROM 'file:///...' AS row:
CALL apoc.merge.node(
[row[1]],
{id: row[2]}
) yield node
return node
Upvotes: 1
Reputation: 30397
You can't create nodes with dynamic labels, or relationships with dynamic types supplied by string variables in Cypher.
You'll need to use APOC Procedures for this instead, specifically the procedures for creating data.
An example of usage:
using periodic commit load csv from... as row
call apoc.create.node([row[1]], {name:row[2]}) yield node
Dynamic merges aren't covered yet, unfortunately, just creates.
Upvotes: 4