Last active
December 23, 2019 10:45
-
-
Save mneedham/1ad3733452f90730fd3de7595121e637 to your computer and use it in GitHub Desktop.
Guardian Top 100 Male Footballers - https://markhneedham.com/blog/2019/12/22/quick-graph-guardian-top-100-male-footballers/
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
CALL apoc.schema.assert(null,{Judge:['id'], Player:["name"], Country:["name"], Club:["name"]}); | |
WITH "1f4nc8vehOiZhEB2_3L2bvXTpag29VcEKJ0PJeo5Runc" AS id | |
WITH "https://docs.google.com/spreadsheets/d/" + id + "/export?format=csv&id=" + id + "&gid=3" AS uri | |
LOAD CSV FROM uri AS row | |
WITH row SKIP 4 LIMIT 100 | |
MERGE (player:Player {name: row[8]}) | |
SET player.rawScore = toInteger(row[14]), player.score = toInteger(row[16]) | |
MERGE (country:Country {name: row[9]}) | |
MERGE (club:Club {name: row[10]}) | |
MERGE (clubCountry:Country {name: row[11]}) | |
MERGE (player)-[:NATIONALITY]->(country) | |
MERGE (player)-[:PLAYS_FOR]->(club) | |
MERGE (club)-[:PLAY_IN]->(clubCountry) | |
FOREACH(index in range(19, size(row)-1) | | |
MERGE (judge:Judge {id: index-18}) | |
FOREACH(ignoreMe IN CASE WHEN row[index] is null THEN [] ELSE [1] END | | |
MERGE (judge)-[voted:VOTED]->(player) | |
SET voted.score = toInteger(row[index]) | |
)); | |
WITH "1f4nc8vehOiZhEB2_3L2bvXTpag29VcEKJ0PJeo5Runc" AS id | |
WITH "https://docs.google.com/spreadsheets/d/" + id + "/export?format=csv&id=" + id + "&gid=3" AS uri | |
LOAD CSV FROM uri AS row | |
WITH row SKIP 105 LIMIT 80 | |
MERGE (player:Player {name: row[8]}) | |
SET player.rawScore = toInteger(row[14]), player.score = toInteger(row[16]) | |
MERGE (country:Country {name: row[9]}) | |
MERGE (club:Club {name: row[10]}) | |
MERGE (clubCountry:Country {name: row[11]}) | |
MERGE (player)-[:NATIONALITY]->(country) | |
MERGE (player)-[:PLAYS_FOR]->(club) | |
MERGE (club)-[:PLAY_IN]->(clubCountry) | |
FOREACH(index in range(19, size(row)-1) | | |
MERGE (judge:Judge {id: index-18}) | |
FOREACH(ignoreMe IN CASE WHEN row[index] is null THEN [] ELSE [1] END | | |
MERGE (judge)-[voted:VOTED]->(player) | |
SET voted.score = toInteger(row[index]) | |
)); | |
WITH "1f4nc8vehOiZhEB2_3L2bvXTpag29VcEKJ0PJeo5Runc" AS id | |
WITH "https://docs.google.com/spreadsheets/d/" + id + "/export?format=csv&id=" + id + "&gid=3" AS uri | |
LOAD CSV FROM uri AS row | |
WITH row SKIP 186 | |
MERGE (player:Player {name: row[8]}) | |
SET player.rawScore = toInteger(row[14]), player.score = toInteger(row[16]) | |
MERGE (country:Country {name: row[9]}) | |
MERGE (club:Club {name: row[10]}) | |
MERGE (clubCountry:Country {name: row[11]}) | |
MERGE (player)-[:NATIONALITY]->(country) | |
MERGE (player)-[:PLAYS_FOR]->(club) | |
MERGE (club)-[:PLAY_IN]->(clubCountry) | |
FOREACH(index in range(19, size(row)-1) | | |
MERGE (judge:Judge {id: index-18}) | |
FOREACH(ignoreMe IN CASE WHEN row[index] is null THEN [] ELSE [1] END | | |
MERGE (judge)-[voted:VOTED]->(player) | |
SET voted.score = toInteger(row[index]) | |
)); | |
match (club:Club {name: "Bayern Munich"})-[playIn:PLAY_IN]->(:Country {name: "Spain"}) | |
DELETE playIn; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment