Skip to content

Instantly share code, notes, and snippets.

@moxious
Created November 4, 2020 13:08
Show Gist options
  • Select an option

  • Save moxious/9924090e05be42a59820825f1c91252e to your computer and use it in GitHub Desktop.

Select an option

Save moxious/9924090e05be42a59820825f1c91252e to your computer and use it in GitHub Desktop.
Ghengis Khan's Family Tree in Neo4j
WITH 'https://storage.googleapis.com/meetup-data/ghengis-khan-family-tree.csv' as data
LOAD CSV WITH HEADERS FROM data AS line
MERGE (p:Person { id: line.id })
SET
p.name = line.name,
p.born = coalesce(line.born, 'Unknown'),
p.died = coalesce(line.died, 'Unknown')
WITH p, line
MERGE (father:Person { id: coalesce(line.father_id, apoc.create.uuid()) })
MERGE (mother:Person { id: coalesce(line.mother_id, apoc.create.uuid()) })
MERGE (p)-[:FATHER]->(father)
MERGE (p)-[:MOTHER]->(mother);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment