Skip to content

Instantly share code, notes, and snippets.

RES_ENT_ID DATA_SOURCE RECORD_ID
1 CUSTOMERS 1001
1 REFERENCE 1001
1 WATCHLIST 1001
1 CUSTOMERS 1002
1 REFERENCE 1002
1 WATCHLIST 1002
1 CUSTOMERS 1003
1 REFERENCE 1003
1 WATCHLIST 1003
@jvilledieu
jvilledieu / Paradise_enhanced.cql
Last active August 22, 2018 09:55
Queries to extend the paradise papers dataset with pagrank, community detection, geocoding, etc
//Check schema
CALL db.schema()
//Identify countries with limited # of adresses
MATCH (a:Address)
WITH a, a.countries as countries
RETURN countries, count(a) as score
ORDER BY score ASC
LIMIT 50
//Creating companies
CALL apoc.load.json($url) YIELD value
WITH distinct value.home_domain as domain, value.home_name as name
merge (b:Business {domain:domain}) ON CREATE SET b.name = name;
//Creating more companies
call apoc.load.json($url) yield value
with distinct value.link_domain as domain, value.link_name as name
merge (b:Business {domain:domain}) ON CREATE SET b.name = name;
@jvilledieu
jvilledieu / EA.cql
Last active April 13, 2017 08:34
Enterprise Architecture dataset for Neo4j
CREATE (:OrganizationUnit { name: "OrganizationUnit"})
FOREACH (r IN range(0,3)|
CREATE (:ICTObject{ name:"ICTObject" + r}))
FOREACH (r IN range(0,3)|
CREATE (:BusinessActor{ name:"BusinessActor" + r}))
FOREACH (r IN range(0,3)|
CREATE (:ApplicationService{ name:"ApplicationService" + r}))
FOREACH (r IN range(0,3)|
CREATE (:Process{ name:"Process" + r}))
CREATE (:BillOfMaterial { name: "BoM", cost: 500})
FOREACH (r IN range(0,10)|
CREATE (:Retailer { name:"Retailer" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: 1}))
FOREACH (r IN range(0,1)|
CREATE (:Wholesaler { name:"Wholesaler" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)}))
;
CREATE (:Product { name: "ProductA", lat: tan(rand())*100, long: tan(rand())*100, co2: 200, cost: 100, time: 0 })
FOREACH (r IN range(0,2)|
CREATE (:Supplier { name:"SupplierA" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)}))
@jvilledieu
jvilledieu / import_generalsofgold.cql
Created March 14, 2017 17:28
Import script for the generals' of gold.
// Verifying the CSV file
// assert correct line count
LOAD CSV FROM "file:/Developer/TGOG/data/person.csv" AS line
RETURN count(*);
// check first few raw lines
LOAD CSV FROM "file:/Developer/TGOG/data/person.csv" AS line WITH line
RETURN line
LIMIT 1;
@jvilledieu
jvilledieu / import_trump_world.cql
Created January 16, 2017 09:03
Importing the Buzzfeed Trump World data into Neo4j (Based on Michael Hunger's work)
//Creating unique constraint
CREATE CONSTRAINT ON (o:Organization) ASSERT o.name IS UNIQUE;
//Importing the organizations and their connections
WITH 'https://docs.google.com/spreadsheets/u/1/d/1Z5Vo5pbvxKJ5XpfALZXvCzW26Cl4we3OaN73K9Ae5Ss/export?format=tsv&id=1Z5Vo5pbvxKJ5XpfALZXvCzW26Cl4we3OaN73K9Ae5Ss&gid=634968401' AS url, ['LOAN','LOBBIED','SALE','SUPPLIER','SHAREHOLDER','LICENSES','AFFILIATED','TIES','NEGOTIATION','INVOLVED','PARTNER'] as terms
load csv with headers from url as row fieldterminator '\t'
MERGE (a:Organization {name:row.`Organization A`})
MERGE (b:Organization {name:row.`Organization B`})
CREATE (a)-[:IS_CONNECTED_TO {type:row.Connection}]->(b);
@jvilledieu
jvilledieu / aml_demo.cql
Last active July 22, 2019 12:31
Import script for the aml demo
//Creating the companies
CREATE CONSTRAINT ON (a:COMPANY) ASSERT a.id IS UNIQUE;
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:///companies.csv" AS line
FIELDTERMINATOR ','
WITH line
MERGE (a:COMPANY {id: line.id})
ON CREATE SET a.description = line.description,
a.name = line.name;
@jvilledieu
jvilledieu / updated_crunchbase_script.cql
Last active August 18, 2016 12:12
New crunchbase import script
/*
https://linkurio.us/the-crunchbase-graph-data-modelling/
https://linkurio.us/crunchbase-graph-importing-data-neo4j/
https://linkurio.us/crunchbase-graph-analysing-graph/
Check also Neo4j csv and etl guide
*/
@jvilledieu
jvilledieu / intelligence_dataset_import.cql
Last active August 14, 2017 05:38
Import intelligence dataset
//Clean up the db
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
//-----------------------
//Import persons
//-----------------------
CREATE CONSTRAINT ON (a:Person)
ASSERT a.id IS UNIQUE;