Skip to content

Instantly share code, notes, and snippets.

@jvilledieu
Last active August 29, 2015 14:13
Show Gist options
  • Save jvilledieu/89b88661925cc4299f44 to your computer and use it in GitHub Desktop.
Save jvilledieu/89b88661925cc4299f44 to your computer and use it in GitHub Desktop.
Import script to populate Neo4j with an AML dataset.
//-----------------------
//Import the companies
//-----------------------
CREATE CONSTRAINT ON (e:COMPANY) ASSERT e.id IS UNIQUE;
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/companies.csv" AS line
MERGE (:COMPANY { id: line.id, company_name: line.company_name, city: line.city, country: line.country, postal_code: line.postal_code, state: line.state, address: line.address});
//-----------------------
//Import the persons
//-----------------------
CREATE CONSTRAINT ON (e:PERSON) ASSERT e.id IS UNIQUE;
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/people.csv" AS line
MERGE (:PERSON { id: line.id, first_name: line.first_name, last_name: line.last_name, full_name: line.full_name, gender: line.gender, ssn: line.ssn});
//-----------------------
//Import the accounts
//-----------------------
CREATE CONSTRAINT ON (e:ACCOUNT) ASSERT e.id IS UNIQUE;
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/iban.csv" AS line
MERGE (:ACCOUNT { id: line.id, iban: line.iban});
//-----------------------
//Create the relationships
//-----------------------
//Link people and companies to bank accounts
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/rels1.csv" AS line
MATCH (a {id: line.FROM})
MATCH (b {id: line.TO})
MERGE (a)-[:HAS_ACCOUNT]->(b);
//Link bank accounts to bank accounts
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/rels2.csv" AS line
MATCH (a {id: line.FROM})
MATCH (b {id: line.TO})
MERGE (a)-[:SENDS_TO]->(b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment