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
WITH "https://vbatushkov.bitbucket.io/swapi.json" AS url | |
CALL apoc.load.json(url) YIELD value | |
UNWIND value.species as species | |
MATCH (spec:Species { url: species.url }) | |
MATCH (p:Planet { url: species.homeworld }) | |
MERGE (spec)-[:HOMEWORLD]->(p) |
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
MERGE (c1:City { name: "Folkestone" }) | |
MERGE (c2:City { name: "Calais" }) | |
WITH c1, c2 | |
UNWIND range(1, 31) as day | |
WITH CASE WHEN date({ year: 2019, month: 5, day: day }).dayOfWeek > 5 THEN 9 ELSE 7 END as morningH, CASE WHEN date({ year: 2019, month: 5, day: day }).dayOfWeek > 5 THEN 21 ELSE 20 END as eveningH, c1, c2, day | |
MERGE (t1:Trip { code: "1_" + day, departure: DateTime({ year: 2019, month: 5, day: day, hour: morningH }), arrival: DateTime({ year: 2019, month: 5, day: day, hour: morningH, minute: 35 }) }) | |
MERGE (t2:Trip { code: "2_" + day, departure: DateTime({ year: 2019, month: 5, day: day, hour: eveningH }), arrival: DateTime({ year: 2019, month: 5, day: day, hour: eveningH, minute: 35 }) }) | |
MERGE (t3:Trip { code: "3_" + day, departure: DateTime({ year: 2019, month: 5, day: day, hour: morningH }), arrival: DateTime({ year: 2019, month: 5, day: day, hour: morningH, minute: 35 }) }) | |
MERGE (t4:Trip { code: "4_" + day, departure: DateTime({ year: 2019, month: 5, day: day, hour: eveningH }), arrival: Date |
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
MATCH (t:Trip)--(c:City) | |
WHERE t.departure.day = 6 | |
RETURN t, c |
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
MATCH (c1:City { name: "Calais" })<-[:FROM]-(t1:Trip) | |
MATCH (c2:City { name: "Folkestone" })<-[:FROM]-(t2:Trip) | |
WHERE t1.departure.day = 6 AND t1.departure.hour = 7 AND t2.departure.day = 12 AND t2.departure.hour = 21 | |
RETURN t1, t2, c1, c2 |
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
MATCH (tr1:Trip { code: "3_7" }) | |
MATCH (tr2:Trip { code: "2_12" }) | |
MERGE (p1:Passenger { name: "Vlad Batushkov", passport: "XXX" }) | |
MERGE (p2:Passenger { name: "Katerina Batushkova", passport: "XXX" }) | |
MERGE (t1:Ticket { sitNo: 7, wagon: 3 }) | |
MERGE (t2:Ticket { sitNo: 8, wagon: 3 }) | |
MERGE (t3:Ticket { sitNo: 1, wagon: 1 }) | |
MERGE (t4:Ticket { sitNo: 2, wagon: 1 }) | |
MERGE (b:Booking { createdAt: localdatetime() }) | |
MERGE (p:Payment { createdAt: localdatetime(), status: "Paid", amount: 400, transactionCode: "XXX" }) |
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
WITH ("http://www.morze.ru/radio_tv/radio_tv1.htm") as url | |
CALL apoc.load.html(url, { waves: "td.boldtabl"}) YIELD value | |
WITH apoc.coll.pairsMin(value.waves)[0..50] as val | |
UNWIND val as v | |
WITH toFloat(apoc.text.replace(v[0].text, ",", ".")) as fm1, toFloat(apoc.text.replace(v[1].text, ",", ".")) as fm2 | |
WITH apoc.math.round(fm2 - fm1, 1) as diff, fm1, fm2 | |
MERGE (w1:Wave { fm: toString(fm1) + " FM" }) | |
MERGE (w2:Wave { fm: toString(fm2) + " FM" }) | |
MERGE (w1)-[:NEXT { diff: diff }]->(w2) |
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
MATCH (w1:Wave)-[d:NEXT*2]->(w2:Wave) | |
WITH w1, w2, reduce(result = 0, x in d | result + x.diff) as diff | |
RETURN w1, w2, max(diff) as max_diff | |
ORDER BY max_diff DESC | |
LIMIT 3 |
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
WITH "https://www.fragranceoutlet.com/pages/brands" as url | |
CALL apoc.load.html(url, { data: "li.brand a" }) YIELD value | |
UNWIND value.data as brand | |
MERGE (b:Brand { name: brand.text, url: brand.attributes.href }) |
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
WITH ["4", "I", "O"] as list | |
MATCH (b:Brand) | |
WHERE apoc.coll.contains(list, left(b.name, 1)) = true | |
WITH "https://www.fragranceoutlet.com" + b.url as url, b | |
CALL apoc.load.html(url, { products: "a.product-grid-item p.product-title" }) YIELD value | |
UNWIND value.products as product | |
MERGE (p:Product { name: product.text }) | |
MERGE (p)-[:PRODUCED_BY]->(b) |
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
WITH ("https://ru.wikipedia.org/wiki/%D0%91%D0%B5%D1%81%D1%81%D0%BC%D0%B5%D1%80%D1%82%D0%BD%D1%8B%D0%B9_%D0%BF%D0%BE%D0%BB%D0%BA") as url | |
CALL apoc.load.html(url, { list: "table:not([class]) ul li" }) YIELD value | |
UNWIND value.list as item | |
WITH split(replace(item.text, ' - ', ' - '), '-') as arr | |
WITH trim(arr[0]) as countryName, apoc.text.regexGroups(trim(arr[1]), "[0-9]{4}")[0][0] as year | |
WITH length(countryName) / 2 as middle, countryName, year | |
WITH CASE WHEN left(countryName, middle) = right(countryName, middle) THEN left(countryName, middle) ELSE countryName END as cn, year | |
MERGE (y:Year { value: year }) | |
MERGE (c:Country { name: cn }) | |
MERGE (c)-[:JOINED_AT]->(y) |