Last active
February 17, 2019 14:28
-
-
Save nicolewhite/f1980f01dc4342b369a6b3b6950a40c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.