Skip to content

Instantly share code, notes, and snippets.

@vladbatushkov
Created May 9, 2019 15:59
Show Gist options
  • Save vladbatushkov/56ee92fbc0e966e4b3de9ddab08b6cfd to your computer and use it in GitHub Desktop.
Save vladbatushkov/56ee92fbc0e966e4b3de9ddab08b6cfd to your computer and use it in GitHub Desktop.
Grab data of Immortal Regiment.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment