I am have a Python program that reads data from an Oracle database into a Pandas DataFrame.
I then use Cypher to unwind the rows and create nodes with properties.
Sometimes the values returned from Oracle are null. In the case of numeric fields, the value of the property gets set to NaN.
Is there a way in Cypher to test a value in the unwound row and only create the property if the value meets a certain condition?
Yes it is possible, here are some links to help you:
Example code would be really helpful.
Sure, but should give us your current Cypher query...
The query is below. I pass in a Pandas DataFrame that is populated from a query to Oracle. If a numeric field in Oracle is null, the DataFrame contains nan. These get created a properties with a value of NaN in Neo4j. I tried changing the nan to None in the DataFrame. WIth that, the properties get created with 0.0 as the value.
What I would really like to do is only create the property if there is a value.
def createEntries(rows, batch_size=10000):
query = '''UNWIND $rows AS row
RETURN count(*) as total
return insert_data(query, rows, batch_size)
I advice you to do the pre-treatment in Python, if you want the propery to not be created, the value must be
None in your DataFrame. So replace
NaN values by