cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Add attributes to nodes in batches

I encountered a problem: how to add attributes for 100,000 nodes, there are already 1000000 nodes in the database. The attributes to be added are stored in a csv table.Thank you very much!

2 REPLIES 2

Use LOAD CSV to import the data into Neo4j: https://neo4j.com/docs/cypher-manual/current/clauses/load-csv/

For each line in the CSV, match the node whose property you are adding, and then add it with Cypher according to the format of the CSV. This requires that you have a "key" to find the right node in your input CSV, but the rest is straightforward. You can use the cypher SET clause to put new attributes on any node you match.

First of all, thank you for your help! I queried the link information and completed the work of adding node attributes. However, I cannot complete the task of adding or setting node labels. What should I do?Thank you very much!
The command I used was::auto USING PERIODIC COMMIT 300 LOAD CSV FROM 'file:///test.csv' AS line match (a) where a.id=line[0] set a.p1=line[1],a.p2=line[2],a:line[3].