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.

Merging nodes with common identities from multiple CSV files

Reuben
Graph Buddy

1. I have an existing CSV file from which I have converted the details into nodes and relationships:

LOAD CSV WITH HEADERS FROM $path AS row
MERGE (f:food {food_name: row.food_name})
MERGE (m:material {material: row.material})
MERGE (f)-[:material]->(m)

2. Now, I have another CSV file with one column called material, with common elements as in (m:material {material: row.material}). With this CSV file I want to set the other columns and rows, and properties to "m" without creating a a new node for the nodes with the same indentities.

LOAD CSV WITH HEADERS FROM $path AS row
MERGE (mt:materials {materials: row.Material_name})
SET mt.English_name = row.English, mt.Grade = row.Grade, mt.Standard = row.Standard

#Neo4j #CSV #match #Merge

2 ACCEPTED SOLUTIONS

Hi Reuben,

from looking at your code, I think the only problem with that is a spelling mistake. In your second line of the second cypher block, it says

MERGE (mt:materials {materials: row.Material_name})

instead of

MERGE (mt:material {material: row.Material_name})

i.e. the "s" in the Label and the "s" in the property name are different to the nodes that you create in your first cypher block where these two s's are not present.

If you correct these, your aim should be achieved with exactly that code.

Regards,
Elena

View solution in original post

Hi Reuben,

yes, I understood what you want to achieve. What I am saying is that the following the cypher queries that your wrote are almost perfect and you just need to delete the additional s's in your second line of your second block and then you get your desired result.

View solution in original post

4 REPLIES 4

Hi Reuben,

from looking at your code, I think the only problem with that is a spelling mistake. In your second line of the second cypher block, it says

MERGE (mt:materials {materials: row.Material_name})

instead of

MERGE (mt:material {material: row.Material_name})

i.e. the "s" in the Label and the "s" in the property name are different to the nodes that you create in your first cypher block where these two s's are not present.

If you correct these, your aim should be achieved with exactly that code.

Regards,
Elena

Thanks, Elena,for the swift respose,please I hope this image makes my intentions clearertrial.png

Hi Reuben,

yes, I understood what you want to achieve. What I am saying is that the following the cypher queries that your wrote are almost perfect and you just need to delete the additional s's in your second line of your second block and then you get your desired result.

Reuben
Graph Buddy

Got it now.Thanks!

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online