Skip to content

Instantly share code, notes, and snippets.

//Clean up the db
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
//-----------------------
//Import people
//-----------------------
CREATE CONSTRAINT ON (a:EMPLOYEE)
ASSERT a.Employee_ID IS UNIQUE;
We can't make this file beautiful and searchable because it's too large.
company_permalink,company_name,company_category_list,company_market,company_country_code,company_state_code,company_region,company_city,funding_round_permalink,funding_round_type,funding_round_code,funded_at,funded_month, funded_quarter ,funded_year, raised_amount_usd
/organization/waywire,#waywire,|Entertainment|Politics|Social Media|News|,News,USA,NY,New York City,New York,/funding-round/cc409188fa2b63482bd9008f682c2efa,seed,,30/06/2012,2012-06, 2012-Q2 ,2012, 1 750 000
/organization/tv-communications,&TV Communications,|Games|,Games,USA,CA,Los Angeles,Los Angeles,/funding-round/86d22afc65107b6941e6c43c671ecbb8,undisclosed,,04/06/2010,2010-06, 2010-Q2 ,2010, 1 000 000
/organization/tv-communications,&TV Communications,|Games|,Games,USA,CA,Los Angeles,Los Angeles,/funding-round/59a3669a64e39360c2b939300bcda162,undisclosed,,23/09/2010,2010-09, 2010-Q3 ,2010, 3 000 000
/organization/rock-your-paper,'Rock' Your Paper,|Publishing|Education|,Publishing,EST,,Tallinn,Tallinn,/funding-round/f06b420775f7cb6c1541a
@jvilledieu
jvilledieu / Analysing Crunchbase
Last active August 29, 2015 14:08
Cypher queries for Crunchbase. This is used to create analyse Crunch via Neo4j (see blog post: http://linkurio.us/the-crunchbase-graph-data-modelling/). The data remains the property of Crunchbase and its use is limited by the following license: https://info.crunchbase.com/docs/licensing-policy-v1/
//What is the biggest startup scene?
MATCH (a:CITY)<-[:HAS_CITY]-(b:COMPANY)
RETURN a.name as city, count(b) as score
ORDER BY score DESC
LIMIT 5
//What is the market positioning of startups in San Francisco
MATCH (a:CITY {name:'San Francisco'})<-[:HAS_CITY]-(b:COMPANY)
WITH b
MATCH b-[:HAS_MARKET]->(c:MARKET)
@jvilledieu
jvilledieu / dummy_call_records_analysis
Created December 1, 2014 15:56
Dummy dataset of call records
ID,FULL_NAME,FIRST_NAME,LAST_NAME,CALLING_NBR,CALLED_NBR,START_DATE,END_DATE,DURATION,CITY,STATE,ADDRESS,CELL_TOWER
1,RalphJordan,Ralph,Jordan,8-(921)364-8515,3-(230)472-4011,1419197491,1419198397,906,Fair Oaks,CA,27834 Glendale Hill,0080
2,PamelaPowell,Pamela,Powell,2-(270)359-8113,2-(833)444-8281,1416290807,1416292942,2135,West Sacramento,CA,35593 Portage Drive,0051
3,AnnaGibson,Anna,Gibson,3-(307)801-5521,9-(490)378-2330,1417817803,1417820157,2354,Sacramento,CA,1323 El Camino Avenue,0102
4,BeverlyKelly,Beverly,Kelly,7-(423)821-7199,3-(307)801-5521,1417220166,1417223469,3303,Folsom,CA,28473 Hanson Plaza,0081
5,RobertBowman,Robert,Bowman,7-(445)366-2890,2-(833)444-8281,1415288003,1415289004,1001,Sacramento,CA,4 Waubesa Plaza,0032
6,WalterWright,Walter,Wright,9-(375)425-6362,8-(618)141-5320,1414689052,1414691454,2402,Orangevale,CA,97 Briar Crest Plaza,0079
7,WalterWright,Walter,Wright,9-(375)425-6362,3-(812)536-3510,1419461129,1419462362,1233,Sacramento,CA,11746 Moose Crossing,0059
8,AnnaGibson,Anna,Gibson,3-
//Importing the file Companies.csv
//Creating the constraints
create constraint on (a:COMPANY) assert a.permalink is unique;
create constraint on (e:CITY) assert e.name is unique;
//Creating the companies & Cities
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/Companies.csv" AS line
FIELDTERMINATOR ';'
@jvilledieu
jvilledieu / Call_records_dummy
Created January 12, 2015 10:12
Dummy dataset for call records analysis article.
ID,FULL_NAME,FIRST_NAME,LAST_NAME,CALLING_NBR,CALLED_NBR,START_DATE,END_DATE,DURATION,CITY,STATE,ADDRESS,CELL_SITE
1,RalphJordan,Ralph,Jordan,8-(921)364-8515,3-(230)472-4011,1419197491,1419198397,906,Fair Oaks,CA,27834 Glendale Hill,0080
2,PamelaPowell,Pamela,Powell,2-(270)359-8113,2-(833)444-8281,1416290807,1416292942,2135,West Sacramento,CA,35593 Portage Drive,0051
3,AnnaGibson,Anna,Gibson,3-(307)801-5521,9-(490)378-2330,1417817803,1417820157,2354,Sacramento,CA,1323 El Camino Avenue,0102
4,BeverlyKelly,Beverly,Kelly,7-(423)821-7199,3-(307)801-5521,1417220166,1417223469,3303,Folsom,CA,28473 Hanson Plaza,0081
5,RobertBowman,Robert,Bowman,7-(445)366-2890,2-(833)444-8281,1415288003,1415289004,1001,Sacramento,CA,4 Waubesa Plaza,0032
6,WalterWright,Walter,Wright,9-(375)425-6362,8-(618)141-5320,1414689052,1414691454,2402,Orangevale,CA,97 Briar Crest Plaza,0079
7,WalterWright,Walter,Wright,9-(375)425-6362,3-(812)536-3510,1419461129,1419462362,1233,Sacramento,CA,11746 Moose Crossing,0059
8,AnnaGibson,Anna,Gibson,3-(
@jvilledieu
jvilledieu / Import_ballon_or.cql
Last active August 29, 2015 14:13
Script to import the votes from the Ballon d'Or 2014 into a Neo4j graph.
CREATE CONSTRAINT ON (e:PERSON) ASSERT e.name IS UNIQUE;
CREATE CONSTRAINT ON (e:TYPE) ASSERT e.name IS UNIQUE;
CREATE CONSTRAINT ON (e:COUNTRY) ASSERT e.name IS UNIQUE;
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/ballon_or.csv" AS line
FIELDTERMINATOR ';'
MERGE (:PERSON {name: line.Name, type: line.Voter, country: line.Country})
MERGE (:TYPE {name: line.Voter})
MERGE (:COUNTRY {name: line.Country})
@jvilledieu
jvilledieu / import_AML_dataset.cql
Last active August 29, 2015 14:13
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});
@jvilledieu
jvilledieu / contributions_import.cql
Last active August 29, 2015 14:16
Importing the contribution dataset.
//-----------------------
//Import the contributors
//-----------------------
CREATE INDEX ON :CONTRIBUTOR(`id`);
USING PERIODIC COMMIT 2000
LOAD CSV WITH HEADERS FROM "file:c:/contribution_nodes.csv" AS line
FIELDTERMINATOR ';'
MERGE (:CONTRIBUTOR { id: line.id, size: line.size, organization_type: line.organization_type, committee_type: line.committee_type, party: line.party, name: line.name});
@jvilledieu
jvilledieu / Contributions analysis.cql
Last active August 29, 2015 14:16
Queries to analyse the political contributions
//-----------------------
//Company whose employees donated the more money
//-----------------------
MATCH (a:COMPANY)<-[:IS_EMPLOYED]-(b:INDIVIDUAL)-[r:HAS_CONTRIBUTED]->(c:COMMITTEE)
RETURN a.EMPLOYER, SUM(r.TRANSACTION_AMT) as total
ORDER BY total DESC
LIMIT 10
//-----------------------