Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-17-2021 06:57 PM
I'm trying to merge a new CSV on top of an existing graph, where it merges in new relationships and if the node isn't there yet then it creates one. I tried this but I still get a "source" is missing error.
LOAD CSV WITH HEADERS FROM "file:///crowdfunds_graph.csv" as row
OPTIONAL MATCH (source:Voter {eth: row.source})
OPTIONAL MATCH (target:Voter {eth: row.target})
MERGE (source)-[:crowdfund {contribution: toInteger(row.CF_contribution)}]-(target)
ON CREATE SET source.eth=row.source
ON CREATE SET target.eth=row.target
I'm fairly new to cypher, thanks in advance for any help!
08-18-2021 05:02 AM
Hi @ath310 ,
I think you are trying to do something like
MERGE (source:Voter {eth: row.source})
MERGE (target:Voter {eth: row.target})
MERGE (source)-[:crowdfund {contribution: toInteger(row.CF_contribution)}]-(target)
If you do an OPTIONAL MATCH at the begining, if there's no MATCH, the MERGE phase will try to create a relationship on a null node. Remember that MERGE applies for the entire selector and not just on fragments.
H
All the sessions of the conference are now available online