0
votes

I'm using cypher and the neo4j browser to create nodes from csv input.

I want to read in each row of my csv file with headers and then create a node with that row as properties.

MY current code is:

LOAD CSV WITH HEADERS FROM '<yourFilePath>' AS ROW
WITH ROW 
CREATE (n:node $ROW)

This throws an error saying parameter missing.

2

2 Answers

0
votes

Try this

LOAD CSV WITH HEADERS FROM '<yourFilePath>' AS row
CREATE (n:node)
SET n+= row
0
votes

In Cypher, variables that start with "$" must be passed to the query as parameters. Your Cypher code is locally binding values to the ROW variable (and not passing a parameter), so change $ROW to ROW.

In addition, if you want to make sure that you do not generate duplicate nodes, you should consider using MERGE instead of CREATE. But before you do so, you must carefully read the documentation on MERGE to understand how to use it properly.