Last active
August 29, 2015 14:13
-
-
Save jvilledieu/7bc9cd85df26ce1bf517 to your computer and use it in GitHub Desktop.
Script to import the votes from the Ballon d'Or 2014 into a Neo4j graph.
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
CREATE CONSTRAINT ON (e:PERSON) ASSERT e.name IS UNIQUE; | |
CREATE CONSTRAINT ON (e:TYPE) ASSERT e.name IS UNIQUE; | |
CREATE CONSTRAINT ON (e:COUNTRY) ASSERT e.name IS UNIQUE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/ballon_or.csv" AS line | |
FIELDTERMINATOR ';' | |
MERGE (:PERSON {name: line.Name, type: line.Voter, country: line.Country}) | |
MERGE (:TYPE {name: line.Voter}) | |
MERGE (:COUNTRY {name: line.Country}) | |
MERGE (:VOTER {name: line.Voter}); | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/ballon_or.csv" AS line | |
FIELDTERMINATOR ';' | |
MERGE (:PERSON {name: line.Nominee}); | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/ballon_or.csv" AS line | |
FIELDTERMINATOR ';' | |
MATCH (a:PERSON) | |
MATCH (b:TYPE { name: a.type}) | |
MERGE (a)-[:HAS_TYPE]->(b); | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/ballon_or.csv" AS line | |
FIELDTERMINATOR ';' | |
MATCH (a:PERSON { name: line.Nominee }) | |
SET a:NOMINEE; | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/ballon_or.csv" AS line | |
FIELDTERMINATOR ';' | |
MATCH (a:PERSON) | |
MATCH (b:COUNTRY { name: a.country}) | |
MERGE (a)-[:HAS_COUNTRY]->(b); | |
USING PERIODIC COMMIT 2000 | |
LOAD CSV WITH HEADERS FROM "file:c:/ballon_or.csv" AS line | |
FIELDTERMINATOR ';' | |
MATCH (a:PERSON {name: line.Name}) | |
MATCH (b:PERSON {name: line.Nominee}) | |
MERGE (a)-[:NOMINATED {position: line.Position}]->(b); |
Who voted for who? The Ballon d’Or voting data : https://gist.github.com/jvilledieu/3048e86171fb9048553b
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add degree : MATCH (a:NOMINEE)<-[r:NOMINATED]-(:PERSON) WITH a,count(r) as degree SET a.votes_total = degree