Created
February 27, 2015 17:46
-
-
Save freeeve/04a9136315478a23e623 to your computer and use it in GitHub Desktop.
load movies
This file contains hidden or 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
| LOAD CSV WITH HEADERS FROM 'http://www4.skeweredrook.com/movies.csv' as record | |
| WITH toInt(record.movieId) as movieId, record.title as title, toFloat(record.voteAverage) as avgVote, toInt(record.releaseYear) as releaseYear, | |
| record.tagline as tagline, split(record.genres, ":") as genres, toInt(record.personId) as personId, record.name as personName, | |
| toInt(record.birthYear) as birthYear, toInt(record.deathYear) as deathYear, split(record.characters, ":") as roles, | |
| CASE WHEN record.personType = "ACTOR" THEN [1] ELSE [] END as actor, CASE WHEN record.personType = "DIRECTOR" THEN [1] ELSE [] END as director | |
| MERGE (movie:Movie {id:movieId}) | |
| ON CREATE SET movie.title = title, movie.avgVote = avgVote, movie.releaseYear = releaseYear, movie.tagline = tagline, movie.genres = genres | |
| FOREACH(x in actor | MERGE(person:Person {id:personId}) | |
| ON CREATE SET person.name = personName, person.born = birthYear, person.died = case when deathYear > 0 then deathYear else null end | |
| MERGE (person)-[:ACTED_IN {roles:roles}]->(movie)) | |
| FOREACH(x in director | MERGE(person:Person {id:personId}) | |
| ON CREATE SET person.name = personName, person.born = birthYear, person.died = case when deathYear > 0 then deathYear else null end | |
| MERGE (person)-[:DIRECTED]->(movie)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment