Reputation: 11
I am trying to dynamically create the name of a field in a CSV that I am parsing using FOREACH
.
I am trying this:
// From Load CSV
WITH row,
['NAME-A', 'NAME-B'] AS olink_panels
FOREACH (panel in olink_panels |
MERGE (p:Plate {plate_id: row["Prefix $panel-Suffix"],
name: panel})
)
Neo4j is parsing the code but not creating any new nodes. I suspect it is not evaluating the $panel
variable.
Upvotes: 0
Views: 107
Reputation: 67044
If you are trying to use panel
to generate a header name, this should work:
FOREACH (panel in ['NAME-A', 'NAME-B'] |
MERGE (p:Plate {plate_id: row["Prefix " + panel + "-Suffix"],
name: panel})
)
The $panel
syntax (with the starting dollar sign) should only be used if panel
was passed to the query as a parameter. And Cypher would not do parameter substitution within string literals anyway.
Upvotes: 0