Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-03-2022 03:04 AM - edited 07-03-2022 03:06 AM
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!
Solved! Go to Solution.
07-03-2022 09:57 AM
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
07-03-2022 06:03 AM
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
07-03-2022 06:51 AM
@ glilienfield
Thank you for your suggestion. Unfortunately, the lines with null values still appear, see "ISBN" and "Subtitle":
07-03-2022 09:11 AM
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
07-03-2022 09:47 AM
Are the empty strings vs. null values?
07-03-2022 09:57 AM
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
07-03-2022 10:31 AM
Ingenius solution, thank you!
07-03-2022 10:30 AM
Sorry, I meant: empty strings
07-03-2022 09:37 AM
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.
All the sessions of the conference are now available online