Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Unzip the data-csv.zip file and rename the folder to import.
// Move the import folder into your Neo4j directory.
// $ bin/neo4j start
// $ bin/neo4j-shell < panama_import.cypher
// Delete character at line 31362, position 82 in Addresses.csv before continuing.
// There is an escaped quote; the backslash needs to be removed.
CREATE CONSTRAINT ON (n:Address) ASSERT n.node_id IS UNIQUE;
CREATE CONSTRAINT ON (n:Officer) ASSERT n.node_id IS UNIQUE;
CREATE CONSTRAINT ON (n:Entity) ASSERT n.node_id IS UNIQUE;
CREATE CONSTRAINT ON (n:Intermediary) ASSERT n.node_id IS UNIQUE;
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///Addresses.csv" AS line
CREATE (n:Address {node_id: line.node_id })
SET n += line;
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///Officers.csv" AS line
CREATE (n:Officer {node_id: line.node_id })
SET n += line;
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///Entities.csv" AS line
CREATE (n:Entity {node_id: line.node_id })
SET n += line;
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///Intermediaries.csv" AS line
CREATE (n:Intermediary {node_id: line.node_id })
SET n += line;
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///all_edges.csv" AS line
WITH line
WHERE line.rel_type = "intermediary_of"
MATCH (n:Intermediary {node_id: line.node_1} )
MATCH (m:Entity {node_id: line.node_2} )
CREATE (n)-[:INTERMEDIARY_OF]->(m);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///all_edges.csv" AS line
WITH line
WHERE line.rel_type = "officer_of"
MATCH (n:Intermediary {node_id: line.node_1} )
MATCH (m:Entity {node_id: line.node_2} )
CREATE (n)-[:OFFICER_OF]->(m);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///all_edges.csv" AS line
WITH line
WHERE line.rel_type = "officer_of"
MATCH (n:Officer {node_id: line.node_1} )
MATCH (m:Entity {node_id: line.node_2} )
CREATE (n)-[:OFFICER_OF]->(m);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///all_edges.csv" AS line
WITH line
WHERE line.rel_type = "registered_address"
MATCH (n:Entity {node_id: line.node_1} )
MATCH (m:Address {node_id: line.node_2} )
CREATE (n)-[:REGISTERED_ADDRESS]->(m);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///all_edges.csv" AS line
WITH line
WHERE line.rel_type = "registered_address"
MATCH (n:Intermediary {node_id: line.node_1} )
MATCH (m:Address {node_id: line.node_2} )
CREATE (n)-[:REGISTERED_ADDRESS]->(m);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///all_edges.csv" AS line
WITH line
WHERE line.rel_type = "similar"
MATCH (n:Intermediary {node_id: line.node_1} )
MATCH (m:Intermediary {node_id: line.node_2} )
CREATE (n)-[:SIMILAR]->(m);
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:///all_edges.csv" AS line
WITH line
WHERE line.rel_type = "underlying"
MATCH (n:Entity {node_id: line.node_1} )
MATCH (m:Entity {node_id: line.node_2} )
CREATE (n)-[:UNDERLYING]->(m);
@ChristofferSwanstroem

This comment has been minimized.

Copy link

ChristofferSwanstroem commented May 10, 2016

The last bit that creates relationships based on rel_type = "underlying" does not seem to create any relationships at all! However, the file all_edges.csv contains 1000+ entries with relationships type underlying...

Also, I think one should add the following relationships: Officer - (registered address) -> Address, Officer - (similar) -> Officer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.