Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-22-2020 11:57 AM
I am using Python Driver Bolt api.
cypher = MATCH + WHERE + RETURN + LIMIT
records = tx.run(cypher)
result_set = []
for record in records:
tuple = [record['nname'], record['nid']]
if 'mname' in record and 'mid' in record:
tuple.append(record['mname'])
tuple.append(record['mid'])
result_set.append(tuple)
My records optionally contain fields 'mname' and 'mid' in the result set. However, the test fails when these two fields actually contain values:
if 'mname' in record
and 'mid' in record:`
It's not a standard dict in Python. How to check the presence in such a case?
Solved! Go to Solution.
10-22-2020 12:07 PM
Hello @lingvisa
This function will transform the BOLT result into list of dictionnaries:
def bolt_to_list(result):
return [r.data() for r in result]
You can use like this:
records = bolt_to_list(tx.run(cypher))
You can use classic Python to check for keys
Regards,
Cobra
10-22-2020 12:07 PM
Hello @lingvisa
This function will transform the BOLT result into list of dictionnaries:
def bolt_to_list(result):
return [r.data() for r in result]
You can use like this:
records = bolt_to_list(tx.run(cypher))
You can use classic Python to check for keys
Regards,
Cobra
10-22-2020 12:23 PM
Good to know. Thanks.
All the sessions of the conference are now available online