0

Is there any convenient way to export Neo4j data to csv or GML(for import into Gephi)? I tried to use Gremlin with these command:

g = new Neo4jGraph('~/Documents/neo4j-community-1.9.1/data/graph.db');
g.saveGraphML('Mygraph.xml');

but it returns "null"

I'm not sure what happened exactly... I've got 2 million nodes and 5 million edges in neo4j database,btw.

I know that I can full import Neo4j into Gephi with neo4j-plugin, but maybe the size is too large for that way.. Gephi would hangs when it imported about 300 thousand nodes..

it would be appreciated if any help. Thanks.

Arvin
  • 405
  • 1
  • 8
  • 18
  • 1
    I wrote some helper commands for the neo4j-shell, the `cypher-import` command can also export to CSV https://github.com/jexp/neo4j-shell-tools#cypher-import – Michael Hunger Aug 08 '13 at 12:21

2 Answers2

2

You can use the following cypher:

 CALL apoc.export.graphml.all('graph.graphml', {useTypes:true, storeNodeIds:false})

You will find the GraphML in the import folder of your database. Gephi, yEd, Cytoscape all can import GraphML. Whether millions and billions is possible is another matter of course. Whether it makes sense to visualize millions of nodes is also questionable.

Note that APOC is not installed by default with Neo4j, see the Github repo for more information.

Francois Vanderseypen
  • 1,432
  • 1
  • 12
  • 22
0

Perhaps you should see this question/comments:

error while exporting neo4j to Graphml

I'm assuming that you are getting a "null" in this way from the console which is to be expected. Make sure that you have your Neo4jGraph instances pointed at the correct data directory as well.

You can also write to csv with something like:

http://gremlindocs.com/#recipes/writing-to-file

Community
  • 1
  • 1
stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Writing to file link is dead. – Ben Fulton Apr 08 '20 at 16:59
  • This is a really old answer. You can't write to directly to GML through TinkerPop/Gremlin 3.x. We just don't support that format anymore. You can read about the latest information on IO here: https://tinkerpop.apache.org/docs/current/reference/#io-step and can learn a bit about reading delimited data here: https://tinkerpop.apache.org/docs/current/tutorials/getting-started/ – stephen mallette Apr 08 '20 at 17:38
  • Also this section in the Practical Gremlin book should help: http://kelvinlawrence.net/book/Gremlin-Graph-Guide.html#graphmlandjsonintro – stephen mallette Apr 08 '20 at 17:39
  • Thanks for that. Every link I find in Google seems to be obsolete. – Ben Fulton Apr 13 '20 at 13:15