Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-18-2022 04:38 AM
I would like to use LOAD CSV together with CASE. Depending on a value in one of the columns of each line, nodes with varying label should be created. In my example, I am dealing with two labels ("Input" and "Variable"). I tried the following:
Neo.ClientError.Statement.SyntaxError: Invalid input 'CASE'
08-18-2022 05:03 AM - edited 08-18-2022 06:26 AM
The case statement does not provide that functionality. It is not a control statement, but a method that returns a value.
You have a number of options. You can use the apoc.do.when procedure to do what you tried to do with the case statement.
https://neo4j.com/labs/apoc/4.4/overview/apoc.do/apoc.do.when/
You can use apoc.create.node to create the nodes. This method allows you to pass the label(s) to use.
https://neo4j.com/labs/apoc/4.3/overview/apoc.create/apoc.create.node/
Another option using pure cypher is to use a series of call subqueries to create the nodes, with one call subquery for each different condition. Here is a code snippet to show you the idea:
call{
with line
with line, line.Typ as type
where type = “Input”
MERGE (:Input {name: line.Name})
}
call
{
with line
with line, line.Typ = “Variable”
MERGE (:Variable {name: line.Name})
}
All the sessions of the conference are now available online