Re: [Neo4j] How to delete and recreate the node & relationship when load csv

17 views
Skip to first unread message

Michael Hunger

unread,
Dec 8, 2017, 9:44:41 PM12/8/17
to ne...@googlegroups.com
You don't have to delete them. MERGE is get-or-create and then you can use SET or ON CREATE SET or ON MATCH SET for additional properties.

You delete them by MATCH and then DELETE or DETACH DELETE

On Thu, Dec 7, 2017 at 9:36 AM, Liping Huang <liping.h...@gmail.com> wrote:
Hi there,

When I import the data with "LOAD CSV", how to delete the match nodes, relationships and recreate them in one LOAD CSV statement?


USING PERIODIC COMMIT 50000
LOAD CSV FROM 'file:///data.csv' AS row
MERGE (n: Node{ keyNo: row[0] })
ON CREATE SET
n.key= row[1],
    ......
ON MATCH SET
n.key= row[1],
    ......


Above statement can create new and update the existing nodes, but how to delete the existing one and re-create it?

Thanks

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Liping Huang

unread,
Dec 11, 2017, 3:37:22 AM12/11/17
to Neo4j
Node1 -[rel1]-> Node2
Node1 -[rel2]-> Node3
...... CSV file 1 ......
Node1 -[rel3]-> Node4
Node1 -[rel4]-> Node5
...... CSV file2 ......


for example, i need to delete the rel2, it is eaiser to do it actually, but when using LOAD CSV, seems I need to LOAD the same CSV file twice: 1) delete the relationships  2) re-create the relationship between the nodes, this will involve the not only the IO resource I think.

and for my case, those relationships in multile CSV file, so I cannot DETACH DELETE the nodes when looping the "CSV file 1", this will delete the rel2 and rel3 but this is not as expect.



在 2017年12月9日星期六 UTC+8上午10:44:41,Michael Hunger写道:
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages