问题
I want the query to read the CSV file and create a node for each row in the file.
Here's the query:
CALL apoc.load.csv('FILE:///C:/Temp/Test/Test/Neo4jTest/import/Neo4j_AttributeProvenance.csv',{sep:","}) YIELD map
CALL apoc.create.node(map.NodeType, {key:map.NodeID}) yield node return count(*)
Here's the error:
Can't coerce `RootNode` to List<String>
Here's the data file:
NodeType,NodeID,SchemaName,TableName,AttributeName,DataType,PreviousNodeID
RootNode,queryprocessingtest.q01.testfieldatablec ,queryprocessingtest,q01,testfieldatablec ,varchar,
Node,queryprocessingtest.qc.testfieldatablec ,queryprocessingtest,qc,testfieldatablec ,varchar,queryprocessingtest.q01.testfieldatablec
Node,queryprocessingtest.ttablec.testfieldatablec ,queryprocessingtest,ttablec,testfieldatablec ,varchar,queryprocessingtest.q01.testfieldatablec
回答1:
The first argument of the apoc.create.node
procedure must be an array.
So you need to convert the value of map.NodeType
into an array:
CALL apoc.load.csv('FILE:///C:/Temp/Test/Test/Neo4jTest/import/Neo4j_AttributeProvenance.csv',{sep:","}) YIELD map
CALL apoc.create.node([map.NodeType], {key:map.NodeID}) yield node return count(*)
来源:https://stackoverflow.com/questions/45173312/how-do-i-fix-this-neo4j-apoc-query-that-creates-nodes-froma-csv-file