RETURN: excluding table lines with empty properties

Probably a typical newby question :-)...
I have created the following table:

MATCH (s:Source)
WHERE s.title = $neodash_source_title // value comes from a parameter select function
WITH s LIMIT 1
MATCH (s:Source)-[r:PRODUCED_BY ]->(p:Producer)-[v:HAS_NAME_VARIANT {qualification: "preferred"}]->(n:Name)
WITH [ "Subtitle: " + s.subtitle,
"Year: " + s.year,
"Author: " + n.text,
"ISBN: " + s.ISBN
] as data
UNWIND data as Information
RETURN Information

If e.g. the property "ISBN" is empty, how can I suppress the whole line "ISBN: " + s.ISBN ?
isEmpty will leave the value empty, but "ISBN: " will still appear.

Thanks for any help!

Hello @bennu_neo ,
That seems to do the trick.
The empty strings are created by data-importer.neo4j.io Is there a way to prevent it from creating these NULLs? Thank you.

@ glilienfield
Thank you for your suggestion. Unfortunately, the lines with null values still appear, see "ISBN" and "Subtitle":

Try this. It filters out the elements in your data list that have a size equal to zero. These should be the elements that have properties that are null (don't exists), as "a constant string" + null = null.

MATCH (s:Source)
WHERE s.title = $neodash_source_title  //  value comes from a parameter select function
WITH s LIMIT 1
MATCH (s:Source)-[r:PRODUCED_BY ]->(p:Producer)-[v:HAS_NAME_VARIANT {qualification: "preferred"}]->(n:Name)
WITH [ "Subtitle: " + s.subtitle,
             "Year: " + s.year,
             "Author: " + n.text,
             "ISBN: " + s.ISBN
] as allData
WITH [i in allData where size(i)>0] as data
UNWIND data as Information
RETURN Information

Are the empty strings vs. null values?

Hi @guido !

Thanks for using NeoDash! About your query, looks like you have some empty strings as properties. Can you confirm this theory? In that case, removing empty string properties will improve your model while also reducing a bit your disk usage.

Bennu

Sorry, I meant: empty strings

This should work for empty strings, as a replacement for line 10 that filtered on null values.

WITH [i in allData where not i ends with ': '] as data

Ingenius solution, thank you!