4

I am starting to work with LOAD CSV of Cypher for Neo4J to import larger csv-files into my DB. I would like to add to each imported node a unique ID (uuid) as a property.

My try was:

LOAD CSV FROM "file:..." AS csvLine
CREATE (c:Customer { uuid: {uuid}, name: csvLine[0], code: csvLine[1]})

Unfortunately I receive for each node the same UUID (although its a function that would normally generate the UUID new when called), it looks like the UUID is generated 1 time and then attached to each node while creating the node and parsing the csv-file.

Is there a way to generate a new UUID for each imported csv-line to mark the node?

Thanks for your hints from Balael

4

2 回答 2

7

不确定您在哪里看到 {uuid} 是一个函数。它只是使用您作为参数“uuid”传入的任何内容。

创建 CSV 时,您必须生成一个 uuid。在 cypher 中目前没有uuid()功能。

您可以做的一种解决方法是:

LOAD CSV FROM "file:..." AS csvLine
CREATE (c:Customer { name: csvLine[0], code: csvLine[1]})
SET c.id = id(c)
于 2014-11-22T21:45:52.833 回答
4

您还可以使用GraphAware UUID 模块

您只需将框架 jaruuid 模块 jar放入 plugins 目录,将以下 2 行添加到 neo4j.properties 中,然后重新启动 Neo4j。

com.graphaware.runtime.enabled=true
com.graphaware.module.UIDM.1=com.graphaware.module.uuid.UuidBootstrapper

任何新节点(无论它是如何创建的)都会自动获得一个 UUID。

于 2014-11-23T21:02:22.310 回答