Reputation: 125
I have to load a CSV file having an id (cui), and a name of a disease, some of the ids are repeating themselves but they have a slightly different name. I would like to create the nodes with unique id and nodes for all the other names which are slightly different. the nodes with alternative name will have a relationship [:HAS_ALTERNATIVE_NAME]
with the initial nodes.
I have a query which is appending the alternative names in the node property, this time I will like to normalize the problem by creating a node for each alternative name.
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM 'file:///Concepts_50000.csv' AS line
FIELDTERMINATOR '\t'
MERGE (d:Disease{id: line.CUI})
ON CREATE SET
d.prefered_name = line.name,
d.alternative_name = line.name
ON MATCH SET
d.alternative_name = d.alternative_name+', '+line.name;
In the end, I will like to have something like this situation, one disease having alternative names nodes.
Upvotes: 0
Views: 44
Reputation: 67044
This may do what you want:
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM 'file:///input.csv' AS line
FIELDTERMINATOR '\t'
MERGE (d:Disease {id: line.CUI})
MERGE (n:DiseaseName {name: line.name})
MERGE (d)-[: HAS_ALTERNATIVE_NAME]->(n)
[UPDATED]
For better performance, make sure you have indexes on:
:Disease(id)
:DiseaseName(name)
Upvotes: 1