neo4j:Cypher用uuid加载CSV [英] neo4j: Cypher LOAD CSV with uuid

查看:344
本文介绍了neo4j:Cypher用uuid加载CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用Cypher的LOAD CSV来为Neo4J导入较大的csv文件到我的数据库。我想为每个导入的节点添加一个唯一ID(uuid)作为属性。



我的尝试是:

  LOAD CSV FROMfile:...AS csvLine 
CREATE(c:Customer {uuid:{uuid},name:csvLine [0],code:csvLine不幸的是,我收到每个节点相同的UUID(虽然它的一个函数,它将是一个函数)通常在调用时生成UUID新),它看起来像UUID生成1次,然后附加到每个节点,同时创建节点并解析csv文件。



是否有一种方法为每个导入的csv行生成新的UUID以标记节点?



感谢您来自
的提示Balael

解决方案

不知道你在哪里看到{uuid}是一个函数。
它只是使用你传递的参数作为参数uuid。



在创建CSV时,你必须生成一个uuid。
在cypher中目前没有 uuid()函数。



  LOAD CSV FROMfile:...AS csvLine 
CREATE(c:Customer {name:csvLine [0],code:csvLine [1]})
SET c.id = id(c)


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

解决方案

Not sure where you've seen that {uuid} is a function. It is just using whatever you pass in as an parameter "uuid".

You'd have to generate a uuid when creating your CSV. In cypher there is currently no uuid() function.

One workaround that you could do is:

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

这篇关于neo4j:Cypher用uuid加载CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆