How to parse a collection of lists returned from cypher?
Question: Using python/py2neo, I run a cypher query containing

    
    
    return ..., ...,  collect([node1.uuid, node1.timestamp, id(node1), node2.uuid])
    

Both in web console and py2neo I get back a result looking like this:

    
    
    [ ..., ..., [u'List(1234abcd-1234-1234-1234-1234abcd1234, 1.374650647E9, 13312, 4321abcd-4321-4321-4321-4321abcd4321)', u'List(..., ..., ...)']]
    

(just with `""` instead of `u''` in web console)

It doesn't look like JSON. There's a `u'List()'`, unquoted strings and
scientific notation.

How is it possible to parse returned collections of lists?


Answer: You could do it with regex:

    
    
    import re
    s = u'List(1234abcd-1234-1234-1234-1234abcd1234, 1.374650647E9, 13312, 4321abcd-4321-4321-4321-4321abcd4321)'
    re.findall(r'List\(([a-z0-9-]+), ([0-9.E]+), (\d+), ([a-z0-9-]+)\)', s)
    

this would return:

    
    
    [(u'1234abcd-1234-1234-1234-1234abcd1234',
      u'1.374650647E9',
      u'13312',
      u'4321abcd-4321-4321-4321-4321abcd4321')]
    

