Last active
May 13, 2017 16:21
-
-
Save freeeve/c1ebd6b4c0daa8064d5c678bb572af17 to your computer and use it in GitHub Desktop.
advanced cypher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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