How to use apoc.load.csv in conjunction with apoc.create.node

此生再无相见时 提交于 2019-12-08 04:07:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!