Neo4j: Cypher LOAD CSV with uuid
I am getting started with LOAD CSV Cypher for Neo4J to import large csv files into my DB. I would like to add a unique identifier (uuid) as a property to each imported node.
My attempt:
LOAD CSV FROM "file:..." AS csvLine
CREATE (c:Customer { uuid: {uuid}, name: csvLine[0], code: csvLine[1]})
Unfortunately I am getting the same UUID for each node (although its a function that usually generates a new UUID when called), it looks like the UUID is generated 1 time and then binds to each node when the node is created and parsing the csv file.
Is there a way to create a new UUID for each imported csv line to mark node?
Thanks for your tips from Balael
source to share
Not sure if you've seen {uuid} is a function. It just uses whatever you pass as the "uuid" parameter.
You need to create uuid when creating CSV. There is no function in cypher uuid()
.
One workaround you can do is:
LOAD CSV FROM "file:..." AS csvLine
CREATE (c:Customer { name: csvLine[0], code: csvLine[1]})
SET c.id = id(c)
source to share
You can also use GraphAware UUID Module .
All you have to do is drop the frame frame and uuid jar into the plugins directory, add the following 2 lines to neo4j.properties and restart Neo4j.
com.graphaware.runtime.enabled=true
com.graphaware.module.UIDM.1=com.graphaware.module.uuid.UuidBootstrapper
Any new node (no matter how it is created) will automatically get the UUID.
source to share