Skip to content

Instantly share code, notes, and snippets.

@vladbatushkov
Created May 10, 2019 15:30
Show Gist options
  • Save vladbatushkov/4389612c46bf84a1fb71eb583b6c147c to your computer and use it in GitHub Desktop.
Save vladbatushkov/4389612c46bf84a1fb71eb583b6c147c to your computer and use it in GitHub Desktop.
List all not terminated IATA codes.
MERGE (bkk:Airport { IATA: "BKK" })
WITH ("https://en.wikipedia.org/wiki/List_of_Thai_Airways_destinations") as url, bkk
CALL apoc.load.html(url, { codes: "table.sortable tr[style!=\"background-color:#DDDDDD\"] td:eq(2)" }) YIELD value
WITH filter(code IN value.codes WHERE code.text <> "BKK") as outsideCodes, bkk
UNWIND outsideCodes as code
MERGE (a:Airport { IATA: code.text })
MERGE (bkk)-[:TO]->(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment