Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-07-2019 01:50 PM
I am loading a data set with some missing values. E.g. :Person node always has idNumber, but is sometimes missing dob. I create all the nodes without issues and I have confirmed that there are nodes that have both idNumber and dob and nodes that have idNumber only. The number of loaded nodes matches the number of rows in the input files. Then I try to create a relationship between :Membership and :Person based on memberId and idNumber only:
USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM 'file//my_file.csv' AS row
WITH row
WHERE row.idNumber IS NOT NULL
MERGE (person:Person {idNumber: row:idNumber})
MERGE (membership:Membership {memberId: row.memberId})
CREATE (person)-[:IS_MEMBER]->(membership)
The above statement works only if I load nodes WITHOUT dob property. If nodes have dob property. no relationships are created, even for the nodes that have both idNumber and dob populated. I attempted
MERGE (membership:Membership {memberId: row.memberId, dob:row.dob})
which also failed. How do I create relationships based on a single property? (e.g. I don't care if dob property is present in the node or not, I want to create a relationship based on idNumber and membership ID)
Solved! Go to Solution.
08-07-2019 02:24 PM
You are not setting the dob property when you create the node using MERGE.
Elaine
08-07-2019 02:24 PM
You are not setting the dob property when you create the node using MERGE.
Elaine
08-07-2019 03:09 PM
Edit: you are right, the above solution worked. Thank you!
USING PERIODIC COMMIT 5000
LOAD CSV WITH HEADERS FROM 'file:///myfile.csv' AS row
FIELDTERMINATOR '\t'
MERGE (personl:Person {idNumber: row.idNumber})
SET person.dob=row.birthday
Then in the next step I apply the above code. The relationship is created only if in the first step when I create node I don't add person.dob. It doesn't matter if I add a MERGE on dob when creating a relationship.
All the sessions of the conference are now available online