Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

neo4j: Cypher LOAD CSV with uuid

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

like image 961
Balael Avatar asked Dec 20 '22 09:12

Balael


1 Answers

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)
like image 84
Michael Hunger Avatar answered Dec 24 '22 19:12

Michael Hunger