Neo4j批量CSV加载

8xiog9wr  于 2022-11-05  发布在  其他
关注(0)|答案(1)|浏览(166)

我正在尝试使用以下代码将数据从csv加载到Neo4j中:

WITH ['system1',
'system2',
'system3'] AS systems

UNWIND systems AS system_name

// Get database
//WITH $nodefile AS uri
LOAD CSV WITH HEADERS FROM 'file:///' + system_name + '.csv' AS row
MERGE (n:Database {name:row.schema})
SET n.name = row.schema
;

我收到这个错误。我遗漏了什么?Neo4j Error

zkure5ic

zkure5ic1#

我用自己的测试数据证明了这一点。
你能试试下面的脚本吗?

WITH ['system1',
'system2',
'system3'] AS systems

UNWIND systems AS system_name
LOAD CSV WITH HEADERS FROM 'file:///' + system_name + '.csv' AS row
WITH row WHERE row.schema IS NOT NULL
MERGE (n:Database {name: row.schema});

您不需要最后一行:SET n.name = row.schema,因为如果该名称不存在,则使用合并将创建新节点。

相关问题