How do I fix this Neo4j APOC query that creates nodes froma CSV file?

六眼飞鱼酱① 提交于 2019-12-11 05:28:46

问题


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

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