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

2019-05-29 09:19发布

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(*)

2条回答
唯我独甜
2楼-- · 2019-05-29 09:38

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

查看更多
叛逆
3楼-- · 2019-05-29 10:02

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(*) 
查看更多
登录 后发表回答