Merging nodes with common identities from multiple CSV files

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

Got it now.Thanks!
(migrated from khoros post Solved: Re: Merging nodes with common identities from mult... - Neo4j - 62366)

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 clearer

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.