3

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(*)
Bruno Peres
  • 15,845
  • 5
  • 53
  • 89
nicomp
  • 4,344
  • 4
  • 27
  • 60

2 Answers2

3

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

logisima
  • 7,340
  • 1
  • 18
  • 31
  • That helped. I am now getting a data error so I don't think the query is doing what I think it should be doing. How do I get it to process each line in the CSV and create a node from that line? – nicomp Jul 18 '17 at 17:00
1

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(*) 
Bruno Peres
  • 15,845
  • 5
  • 53
  • 89
  • That helped. I am now getting a data error so I don't think the query is doing what I think it should be doing. How do I get it to process each line in the CSV and create a node from that line? – nicomp Jul 18 '17 at 17:00
  • Hello @nicomp. To answer this question is best to know how your data set looks like. Please, note that probably you are asking a new question in the comments. I recommend you make a new question showing a sample of your data set. Thanks! – Bruno Peres Jul 18 '17 at 17:08
  • https://stackoverflow.com/questions/45173312/how-do-i-fix-this-neo4j-apoc-query-that-creates-nodes-froma-csv-file – nicomp Jul 18 '17 at 17:20