I know this is an old post, but maybe this will help someone else. For those using the Symfony Framework, you can make a fairly simple controller to export the Neo4j Cypher Queries to CSV. To use raw cypher requests, Grapharare NEO4J PHP OGM ( https://github.com/graphaware/neo4j-php-ogm ) is used. I assume this can also be easily implemented without using Symfony using simple PHP.
Just create a form (with a branch if you want):
<form action="{{ path('admin_exportquery') }}" method="get"> Cypher:<br> <textarea name="query"></textarea><br> <input type="submit" value="Submit"> </form>
Then configure the route "admin_exportquery" to point to the controller. And add a controller to handle the export:
public function exportQueryAction(Request $request) { $query = $request->query->get('query'); $em = $this->get('neo4j.graph_manager')->getClient(); $response = new StreamedResponse(function() use($em,$query) { $result = $em->getDatabaseDriver()->run($query); $handle = fopen('php://output', 'w'); fputs( $handle, "\xEF\xBB\xBF" ); $header = $result->getRecords()[0]->keys(); fputcsv($handle, $header); foreach($result->getRecords() as $r){ fputcsv($handle, $r->values()); } fclose($handle); }); $response->headers->set('Content-Type', 'application/force-download'); $response->headers->set('Cache-Control', 'no-store, no-cache'); $response->headers->set('Content-Disposition','attachment; filename="export.csv"'); return $response; }
This allows you to download CSV with utf-8 characters directly from your browser and gives you all the freedom of Cypher.
IMPORTANT: this does not have a request to check what it is, and it is a very good idea to set up an appropriate security check or request before use :)
Joran source share