Neo4j Writer skip empty rows

Hi,

I have a table with several columns one of them is phonenumber. Some of rows in this column are empty (null) (a person did not give a phone as contact). I want to use CYPHER to make a node Phone in the database but skip null rows
I try

UNWIND $batch as row
WHERE NOT row.phonenumber IS NULL
MERGE (n: Phone { number: row.phonenumber })

and also

UNWIND $batch as row
CALL apoc.do.when (row.phonenumber IS NOT NULL,‘MERGE (n: Phone { number: row.phonenumber })’,{}) YIELD value RETURN value

and

UNWIND $batch as row
WITH row
WHERE NOT row.phonenumber IS NULL
CALL {
WITH row
MERGE (n: Phone { number: row.phonenumber })
}

but does not work

Any idea how to do this in Cypher or I have to first filter the empty rows with Row Filter

Thank you
Andrej

Hi @andrejz -

I don’t know if we have many Cypher experts here. Might be a good question for ChatGPT? In the very limited exposure I had to Cypher, I leaned hard on LLMs because the syntax was so specific.

Hi @ScottF

Thank you for the reply. I already try ChatGPT and Bard but doesn’t work. Now I first filter out empty rows and then use Neo4j Writer with simple Cypher and works

Regards
Andrej

1 Like

Hello @andrejz,

I think there are plenty of options you can try:

  • filter out the rows with missing values;
  • there is a checkbox to skip failed queries in Neo4j Writer node, so it should ignore the records with missing values;
  • I think in you first example you should use WHERE-clause after MERGE-clause;
  • you can insert missing values as a property of the node, or you can replace it with a default values and insert them.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.