0
votes

i want to update properties in the relationship by import the csv data in Neo4j. i have created some labels and relationships from csv data like this:

node,name

1,leo

2,sun

3,wang

4,hi

now i would like to add a property "descripe" in the table.

descripe

leader

pro-leader

crew

crew

how can i add this property into the graph? Just only this new property, i dont want to create the new four labels.

THX

1

1 Answers

0
votes

It would be useful if you posted the cypher statements that you used to perform your initial graph creation. Without this it is difficult to know exactly how the update should be written. Essentially though you want to load your csv file containing the new properties, perform a MATCH on the nodes in the graph and then set the properties on these nodes. Assuming that you have created a schema index against your labels it would be something like:

LOAD CSV WITH HEADERS FROM "file:///C:/temp/myfile.csv" AS csvLine
MATCH (n:`Label` { indexedproperty : csvLine.value })
SET n.newproperty = csvLine.newpropertyvalue

where Label is the label you applied to your nodes on creation, indexedproperty is the name of the property you added and indexed, csvLine.value is the lookup value of the indexed property read from the .csv file, csvLine.newpropertyvalue is the new property you wish to add (read from the .csv file).

If you post more details on your graph we can help more precisely.