问题
I need to import a CSV file and create a node from each record. I am using APOC because supposedly I can use a column in the CSV file to define each node type as the nodes are created.
This doesn't work:
CALL apoc.load.csv('FILE:///C:/Temp/Test/Test/Neo4jTest/import/Neo4j_AttributeProvenance.csv',{sep:","}) YIELD map
CALL apoc.create.node(['map.AttributeName'], {key:['map.NodeID']}) return count(*)
This is the error:
Procedure call inside a query does not support naming results implicitly (name explicitly using `YIELD` instead) (line 2, column 1 (offset: 124))
"CALL apoc.create.node(['map.AttributeName'], {key:['map.NodeID']}) return count(*)"
I also tried this syntax:
CALL apoc.load.csv('FILE:///C:/Temp/Test/Test/Neo4jTest/import/Neo4j_AttributeProvenance.csv',{sep:","}) YIELD map
CALL apoc.create.node(map.AttributeName, {key:map.NodeID}) return count(*)
回答1:
Can you try with this :
CALL apoc.load.csv('FILE:///C:/Temp/Test/Test/Neo4jTest/import/Neo4j_AttributeProvenance.csv',{sep:","}) YIELD map
CALL apoc.create.node(['map.AttributeName'], {key:['map.NodeID']}) YIELD node
RETURN count(*)
I just add the YIELD
stuff on the create node.
Cheers
回答2:
You forgot a YIELD node
after call apoc.create.node
procedure. Try this:
CALL apoc.load.csv('FILE:///C:/Temp/Test/Test/Neo4jTest/import/Neo4j_AttributeProvenance.csv',{sep:","}) YIELD map
CALL apoc.create.node(['map.AttributeName'], {key:['map.NodeID']}) YIELD node
return count(*)
来源:https://stackoverflow.com/questions/45172733/how-to-use-apoc-load-csv-in-conjunction-with-apoc-create-node