Re: Load CSV file to addVertex and addEdge


hu junjie <hjj...@...>
 

solved

在 2017年8月15日星期二 UTC+8下午9:48:37,hu junjie写道:

I have an alternative method to solve it. 2 times loop.
new File("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachLine{l->p=l.split(",");v1=g.V().has('uuid',p[0])?:graph.addVertex('uuid',p[0]);v2=g.V().has('uuid',p[1])?:graph.addVertex('uuid',p[1]);}

new File("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachLine{l->p =l.split(",");v1=g.V().has('uuid',p[0]).next();v2=g.V().has('uuid',p[1]).next(); v1.addEdge(p[4],v2)}

在 2017年8月15日星期二 UTC+8下午9:42:40,hu junjie写道:

I have the below gremlin command below. it can work fine.

new File("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachLine{l->p=l.split(",");v1=g.V().has('uuid',p[0])?:graph.addVertex('uuid',p[0]);v2=g.V().has('uuid',p[1])?:graph.addVertex('uuid',p[1]);}

but the below can't work very well.

new File("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachLine{l->p=l.split(",");v1=g.V().has('uuid',p[0])?:graph.addVertex('uuid',p[0]);v2=g.V().has('uuid',p[1])?:graph.addVertex('uuid',p[1]);v1.addEdge(p[4],v2)}

The error is here:

gremlin> new File("data/1a78de40-8f0a-1028-9c9e-db07163b51b2.csv").eachLine{l->p=l.split(",");v1=g.V().has('uuid',p[0])?:graph.addVertex('uuid',p[0]);v2=g.V().has('uuid',p[1])?:graph.addVertex('uuid',p[1]);v1.addEdge(p[4],v2)}

21:30:12 WARN org.janusgraph.graphdb.transaction.StandardJanusGraphTx - Query requires iterating over all vertices [(uuid = 1a78de40-8f0a-1028-9c9e-db07163b51b2)]. For better performance, use indexes 21:30:12 WARN org.janusgraph.graphdb.transaction.StandardJanusGraphTx - Query requires iterating over all vertices [(uuid = d803d140-8f0a-1028-98de-db07163b51b2)]. For better performance, use indexes 21:30:12 WARN org.janusgraph.graphdb.transaction.StandardJanusGraphTx - Query requires iterating over all vertices [(uuid = 1a78de40-8f0a-1028-9c9e-db07163b51b2)]. For better performance, use indexes 21:30:12 WARN org.janusgraph.graphdb.transaction.StandardJanusGraphTx - Query requires iterating over all vertices [(uuid = 92df9f40-8f0a-1028-8723-db07163b51b2)]. For better performance, use indexes No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.addEdge() is applicable for argument types: (java.lang.String, org.janusgraph.graphdb.vertices.StandardVertex) values: [CommunitiesMember, v[122908672]] Type ':help' or ':h' for help. Display stack trace? [yN]

The csv file is below: 1a78de40-8f0a-1028-9c9e-db07163b51b2,d803d140-8f0a-1028-98de-db07163b51b2,2012-09-18T08:56:01Z,1,CommunitiesMember 1a78de40-8f0a-1028-9c9e-db07163b51b2,92df9f40-8f0a-1028-8723-db07163b51b2,2012-09-18T08:56:01Z,1,CommunitiesMember 1a78de40-8f0a-1028-9c9e-db07163b51b2,281edc40-3c20-102c-9a69-980191c9f99a,2012-09-18T08:56:01Z,1,CommunitiesMember 1a78de40-8f0a-1028-9c9e-db07163b51b2,878c73c0-8f0a-1028-91a1-db07163b51b2,2012-09-18T08:56:01Z,1,CommunitiesMember 1a78de40-8f0a-1028-9c9e-db07163b51b2,5427d240-9f1e-102c-9233-9c1aa9e13df3,2012-09-18T08:56:01Z,1,CommunitiesMember

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.