Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export csv file of large resultset using cypher in Neo4j in the browser?

Tags:

neo4j

cypher

I am using Neo4j on my browser on Ubuntu. I got over 1 million nodes and I want to export them as csv file.

When return data size is small like "match n return n limit 3" there is a big fat "download csv" button I could use. But when it comes to big result set like over 1000 the shell just says "Resultset too large(over 1000 rows)" and the button doesnt show up.

How can I export csv files for large resultset?

like image 803
user3692521 Avatar asked Aug 08 '14 16:08

user3692521


People also ask

How to export CSV from Neo4j?

You can already export CSV from the Neo4j Browser by clicking the download icon on the table view of your Cypher query results. Alternatively, you can also use my neo4j-shell-tools to export results of a Cypher query to a CSV file.

What export format does Neo4j browser support?

On recent versions of Neo4j, you can export CSV, SVG or PNG directly from the console - button on top right in attached image.

How do I save a query in Neo4j?

Neo4j stores a few default favorites to get you started. Just click on the Basic Queries, then choose Get Some Data and run the query. This executes the statement MATCH (n) RETURN n limit 100 , which fetches some nodes. You can save your own queries as favorites by "starring" them.


3 Answers

You can also use my shell extensions to export cypher results to CSV.

See here: https://github.com/jexp/neo4j-shell-tools#cypher-import

Just provide an -o output.csv file to the import-cypher command.

like image 196
Michael Hunger Avatar answered Oct 19 '22 06:10

Michael Hunger


Well, I just used linux shell to do all the job.

neo4j-shell -file query.cql | sed 's/|/;/g' > myfile.csv

In my case, I had also to convert from UTF-8 to ISO-8859-1 so I typed:

neo4j-shell -file query.cql | sed 's/|/;/g' | iconv -f UTF-8 -t ISO-8859-1 -o myfile.csv

PS: sed performs the replace: 's/|/;/g' means, substitute (s) all "|" to ";" even though there is more than one per line (g)

Hope this can help.
Regards

like image 27
giscard.faria Avatar answered Oct 19 '22 05:10

giscard.faria


We followed the approach below using mentioned. It works very well for us. data is formatted properly in csv format.

https://github.com/jexp/neo4j-shell-tools#cypher-import

import-cypher command from neo4J shell.

neo4j-sh (?)$ import-cypher -o test.csv MATCH (m:TDSP) return m.name
like image 33
yoga Avatar answered Oct 19 '22 05:10

yoga