Gremlin查询输出到CSV文件

问题描述

我想将gremlin查询返回的输出保存到CSV文件中,其中列名作为属性标签,行作为值:

查询

g.V().as('v1').outE().as('e').inV().as('v2').select('v1','e','v2').by(valueMap()).limit(1)

输出

[
    {
        "v1": {
            "label_A": [
                "A"
            ] 
        },"e": {
            "label_E": "E"
        },"v2": {
            "label_B": [
        “B"
            ]
        }
    }
]

需要Csv文件

label_A,labelB,label_E
A,B,E //row1
.,.,. //row2 
etc

解决方法

虽然它是为Amazon Neptune编写的,但该工具针对Neptune的了解很少:

https://github.com/awslabs/amazon-neptune-tools/tree/master/neptune-export

尤其是:

https://github.com/awslabs/amazon-neptune-tools/blob/master/neptune-export/docs/export-pg-from-queries.md