Skip to content

Instantly share code, notes, and snippets.

@Pablissimo
Created August 1, 2019 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pablissimo/2f7e32989c61a8767b1a07849578f310 to your computer and use it in GitHub Desktop.
Save Pablissimo/2f7e32989c61a8767b1a07849578f310 to your computer and use it in GitHub Desktop.
MATCH (movie: Movie { title: 'Top Gun' })<-[acted_in: ACTED_IN]-(actor: Person)
WITH collect(distinct actor) + movie as nodes, collect(distinct acted_in) as relationships
CALL apoc.export.csv.data(nodes, [], 'nodes.csv', {}) YIELD file as nodefile
UNWIND relationships as relationship
CALL apoc.create.vRelationship(startNode(relationship), type(relationship), { title: relationship.title }, endNode(relationship)) YIELD rel
WITH collect(rel) as relationshipsAmended, nodefile
CALL apoc.export.csv.data([], relationshipsAmended, 'edges.csv', {}) YIELD file as edgefile
RETURN edgefile, nodefile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment