Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-24-2021 11:12 AM
Using Comunity edition 4.3.2 with apoc
I have a question that I wasn't able to solve.
I am importing some data from a CSV file.
In the first round I imported all data that match some business condition. On 900 input lines, I imported 841.
But the other 59 are lost.
So I make another round with the same input file with the following statements:
MATCH (p:Product {ownerid: row.ProductCode})-[:SOLD_BY]->(customer)
My idea was to filter on
WHERE p.ownerid IS NULL
MERGE (p:BadProduct {... properties})
RETURN COUNT(p)
I expected to have a return count of 59, but instead it was 0
the same happened if I use WHERE p IS NULL
Instead, if I use OPTIONAL MATCH
it CREATEs 900 BadProduct nodes
Can someone help or explain how to filter on UNMATCHED conditions (or how to get rid of excluded lines on IMPORT CSV)
Thank you
07-25-2021 10:12 AM
Hello @p.dipietro
You can not match anything on null, null means nothing, not exists at all, null is not a value.
So therefore your MATCH clause will match nothing.
If you do SET p.ownerid = null you destroy the ownerid property from the node and therefore you cannot match on it anymore.
The origin of your lost lines must be in the csv file or in the importation Cypher you used to import them.
07-25-2021 11:33 AM
Hi @tard.gabriel,
Yes, you are absolutely correct about NULL. Maybe there was a type in the query in the previous example.
So, I try to reformulate the question.
I have a set of data coming from a CSV file.
The first row match some conditions and then is added to the DB as a good node.
MATCH (prov:Provider {name: row.provider}
WHERE prov IS NOT NULL
MERGE (n:Product {row.properties...})-[:SOLD_BY]->(prov)
but if the second row doesn't match the first condition I want to add it to the set of BAD nodes
MATCH (prov:Provider {name: row.provider}
WHERE prov IS NULL
MERGE (n:BADProduct {row.properties...})
Is there a way I can use to solve this problem?
All the sessions of the conference are now available online