Skip to content

Instantly share code, notes, and snippets.

@freeeve
Last active May 13, 2017 16:21
Show Gist options
  • Save freeeve/c1ebd6b4c0daa8064d5c678bb572af17 to your computer and use it in GitHub Desktop.
Save freeeve/c1ebd6b4c0daa8064d5c678bb572af17 to your computer and use it in GitHub Desktop.
advanced cypher
// merge movies
LOAD CSV WITH HEADERS FROM 'http://data.neo4j.com.s3.amazonaws.com/advanced/movies/new_movies.csv' AS row
with toFloat(row.avgVote) as avgVote, toInteger(row.releaseYear) as releaseYear, split(row.genres, ":") as genres, toInteger(row.movieId) as id,
row.title as title
merge (m:Movie {id:id})
set m.title = title,m.avgVote = avgVote,m.releaseYear=releaseYear,m.genres = genres
return count(1)
// merge people
LOAD CSV WITH HEADERS FROM 'http://data.neo4j.com.s3.amazonaws.com/advanced/movies/people.csv' as row
with toInteger(row.personId) as id,
toInteger(row.birthYear) as birthYear,
toInteger(row.deathYear) as deathYear,
row.name as name
merge (p:Person {id:id})
set p.name = name,p.born = birthYear,p.died = deathYear
return count(1)
// merge actors
LOAD CSV WITH HEADERS FROM 'file:///actors.csv' as row
MATCH (movie:Movie {id:toInteger(row.movieId)})
MATCH (person:Person {id: toInteger(row.personId)})
MERGE (person)-[r:ACTED_IN]->(movie)
ON CREATE SET person:Actor, r.roles = split(row.characters, ":")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment