Skip to content

Instantly share code, notes, and snippets.

@mneedham
Last active Dec 23, 2019
Embed
What would you like to do?
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