Skip to content

Instantly share code, notes, and snippets.

@tomasonjo
Last active November 25, 2017 16:35
Show Gist options
  • Save tomasonjo/cdd182c53250dc1ab07be2156db43f2d to your computer and use it in GitHub Desktop.
Save tomasonjo/cdd182c53250dc1ab07be2156db43f2d to your computer and use it in GitHub Desktop.
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:///paradise_papers.nodes.officer.csv" as row
MERGE (n:Node{id:row.`n.node_id`})
SET n:Officer
SET n.service_provider = row.`n.service_provider`,
n.jurisdiction_description = row.`n.jurisdiction_description`,
n.status = row.`n.status`,
n.country_codes = row.`n.country_codes`,
n.type = row.`n.type`,
n.note = row.`n.type`,
n.company_type = row.`n.company_type`,
n.address = row.`n.address`,
n.valid_until = row.`n.valid_until`,
n.incorporation_date = row.`n.incorporation_date`,
n.closed_date = row.`n.closed_date`,
n.countries = row.`n.countries`,
n.name = row.`n.name`
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:///paradise_papers.nodes.entity.csv" as row
MERGE (n:Node{id:row.`n.node_id`})
SET n:Entity
SET n.service_provider = row.`n.service_provider`,
n.jurisdiction_description = row.`n.jurisdiction_description`,
n.status = row.`n.status`,
n.country_codes = row.`n.country_codes`,
n.type = row.`n.type`,
n.note = row.`n.type`,
n.company_type = row.`n.company_type`,
n.address = row.`n.address`,
n.valid_until = row.`n.valid_until`,
n.incorporation_date = row.`n.incorporation_date`,
n.closed_date = row.`n.closed_date`,
n.countries = row.`n.countries`,
n.name = row.`n.name`,
n.jurisdiction = row.`n.jurisdiction`
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:///paradise_papers.nodes.intermediary.csv" as row
MERGE (n:Node{id:row.`n.node_id`})
SET n:Intermediary
SET n.service_provider = row.`n.service_provider`,
n.jurisdiction_description = row.`n.jurisdiction_description`,
n.status = row.`n.status`,
n.country_codes = row.`n.country_codes`,
n.type = row.`n.type`,
n.note = row.`n.type`,
n.company_type = row.`n.company_type`,
n.address = row.`n.address`,
n.valid_until = row.`n.valid_until`,
n.incorporation_date = row.`n.incorporation_date`,
n.closed_date = row.`n.closed_date`,
n.countries = row.`n.countries`,
n.name = row.`n.name`,
n.jurisdiction = row.`n.jurisdiction`
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:///paradise_papers.edges.csv" as row
MERGE (n1:Node{id:row.node_1})
MERGE (n2:Node{id:row.node_2})
WITH n1,n2,row
CALL apoc.merge.relationship(n1,toUPPER(row.rel_type),{},{}, n2) yield rel
return distinct "done"
CALL apoc.periodic.iterate(
"MATCH (p1:Officer)-->(:Entity)<--(p2:Officer) where id(p1) < id(p2) RETURN p1,p2",
"MERGE (p1)-[r:RELATED]-(p2) ON CREATE SET r.weight = 1 ON MATCH SET r.weight = r.weight + 1"
, {batchSize:5000, parallel:false,iterateList:true})
@tomasonjo
Copy link
Author

MATCH (e:Entity)
WHERE e.closed_date <> ""
SET e:Closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment