Last active
June 18, 2018 19:32
-
-
Save fferegrino/91ed8a64fd8b1657047caed10d9d8e98 to your computer and use it in GitHub Desktop.
MovieLens database insert
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
LOAD CSV WITH HEADERS FROM 'file:///movies.clean.csv' as l | |
CREATE (m:Movie{movieId:toInteger(l.movieId), tmdbId:l.tmdbId, imdbId:l.imdbId, title:l.title, year:date(l.year)}) | |
CREATE INDEX ON :Movie(movieId) | |
LOAD CSV WITH HEADERS FROM 'file:///users.csv' as l | |
CREATE (u:User{userId:toInteger(l.userId)}) | |
CREATE INDEX ON :User(userId) | |
LOAD CSV WITH HEADERS FROM 'file:///genres.csv' as l | |
MERGE (g:Genre{name:l.genre}) | |
WITH g,l.movieId as movieId | |
MATCH (m:Movie{movieId:toInteger(movieId)}) | |
MERGE (m)-[:IsGenre]->(g) | |
LOAD CSV WITH HEADERS FROM 'file:///ratings.csv' as l | |
MATCH (m:Movie{movieId:toInteger(l.movieId)}) | |
MATCH (u:User{userId:toInteger(l.userId)}) | |
CREATE (u)-[:Rates{rating:toFloat(l.rating), time:datetime(l.time)}]->(m) | |
LOAD CSV WITH HEADERS FROM 'file:///tags.csv' as l | |
MATCH (m:Movie{movieId:toInteger(l.movieId)}) | |
MATCH (u:User{userId:toInteger(l.userId)}) | |
CREATE (u)-[:Tags{tag:l.tag, time:datetime(l.time)}]->(m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment