Creating dynamic nodes with csv upload, doesn't work?

I am uploading a csv file, and tried to generate the nodes with labels that are defined in the csv, i.e. dynamically:

LOAD CSV WITH HEADERS FROM 'nodes.csv' AS row  
MERGE (n:$(row.node_type) {id: row.id});

but I get this error:

Neo.ClientError.Statement.SyntaxError

Invalid input '

I am using the example from the doc:

: expected a node label/relationship type name, '%' or '(' (line 3, column 14 (offset: 92)) " MERGE (n:$(row.node_type) {id: row.id});"


I am using the example from the doc:
https://neo4j.com/docs/cypher-manual/current/clauses/load-csv/

![image](upload://gJzt9gvSrs1PXgQ0fvTZug1HoIN)

Do you have the latest version, as this is when it was released?

@syolbe1

dynamic labels were introduced in Neo4j 5.26.
Also although you can use dynamic labels on cypher statements you should be aware that there is a performance consideration

1 Like

I see, thanks for the quick feedback !

@glilienfield @dana_canzano
indeed it works with 5.26. :+1: